Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Make run-addon use web-ext. Remove autoloading since web-ext handles …
Browse files Browse the repository at this point in the history
…that on its own
  • Loading branch information
ianb committed Feb 10, 2017
1 parent 8c2cd9c commit e06b407
Showing 1 changed file with 12 additions and 84 deletions.
96 changes: 12 additions & 84 deletions bin/run-addon
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ set -e
cd "$(dirname $BASH_SOURCE)/.."
base="$(pwd)"
PATH="node_modules/.bin:$PATH"
no_auto=
upload=
nodemon_pid=
server=http://localhost:10080
scratch=
jpm="$base/node_modules/.bin/jpm"
server=https://localhost:10080
webext="$base/node_modules/.bin/web-ext"

binary=
firefoxes="
Expand All @@ -25,25 +21,6 @@ for firefox in $firefoxes ; do
fi
done

_tempfile=""
writefile () {
local _tempfile="$base/.jpm-json-$$.json"
echo "$1" > $_tempfile
echo "$_tempfile"
}

_cleanup () {
if [[ -n "$_tempfile" ]] ; then
rm -f "$_tempfile"
fi
if [[ -n "$nodemon_pid" ]] ; then
# Seems to usually be dead by this point? Good I guess?
kill $nodemon_pid >& /dev/null || true
fi
}

trap _cleanup EXIT

help () {
echo "Usage: $(basename $0) [OPTIONS]"
echo " Options:"
Expand All @@ -53,8 +30,8 @@ help () {
echo " Use BINARY as the Firefox to run (default $binary)"
echo " --scratch"
echo " Use a scratch profile"
echo " -s or --server URL"
echo " Use the given server (default localhost:10080)"
#echo " -s or --server URL"
#echo " Use the given server (default localhost:10080)"
}


Expand All @@ -73,75 +50,26 @@ while [[ -n "$1" ]] ; do
shift
shift
;;
--upload)
# Note: --upload is a hidden option used when nodemon triggers a restart
upload=1
shift
;;
--scratch)
scratch=1
shift
;;
--server|-s)
server="$2"
shift
shift
;;
#--server|-s)
# server="$2"
# shift
# shift
# ;;
*)
help
exit 2
;;
esac
done

if [[ -n "$upload" ]] ; then
which growlnotify > /dev/null && growlnotify -m "Page Shot Add-on build started." || echo "Page Shot Add-on build started."
if [ -d build ] ; then
# This is to remove empty files that might have resulted from a syntax error:
find build/ -size 0 -exec rm {} \;
fi
make addon xpi
echo "Uploading to the browser"
echo " (if this fails, install: https://addons.mozilla.org/en-US/firefox/addon/autoinstaller/)"
# Doesn't return any content, leads to an unnecessary error:
wget --post-file=build/mozilla-pageshot.xpi http://localhost:8888 || echo "no content"
which growlnotify > /dev/null && growlnotify -m "Page Shot Add-on build finished." || echo "Page Shot Add-on build finished."
exit
fi

prefs="{\"xpinstall.signatures.required\": false, \"extensions.sdk.console.logLevel\": \"all\""
if [[ -n "$server" ]] ; then
prefs="${prefs}, \"extensions.jid1-NeEaf3sAHdKHPA@jetpack.backend\": \"$server\""
fi
prefs="${prefs}}"
file="$(writefile "$prefs")"
_tempfile=$file
make addon

if [[ -z "$no_auto" ]] ; then
nodemon \
-w addon/ -w static/ -w shared/ \
-w Makefile \
--on-change-only \
-e .js,.scss,.css,.png,.svg,.ttf,.html \
--exec bash $0 -- --upload &
nodemon_pid=$!

fi

cd build/addon
profile_option=
if [[ -z "$scratch" ]] ; then
mkdir -p ../../Profile
profile_option="--profile ../../Profile"
mkdir -p ./Profile
profile_option="--firefox-profile ./Profile/"
fi

$jpm run --binary $binary $profile_option --no-copy --prefs $file \
2>&1 \
| grep --line-buffered \
-v -e 'WARNING: content window passed to PrivateBrowsingUtils.isWindowPrivate' \
-v -e '^JavaScript Warning' \
-v -e 'Using ... to indicate source[a-zA-Z]*URL' \
-v -e 'JavaScript 1.7.s let blocks' \
-v -e 'mutating the ..Prototype.. of an object' \
-v -e '^AlarmService'
$webext run --firefox "$binary" $profile_option --browser-console --source-dir ./webextension/

0 comments on commit e06b407

Please sign in to comment.