Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/scripts/extension.sh
#!/usr/bin/env bash | #!/usr/bin/env bash | ||||
export LC_ALL=C | export LC_ALL=C | ||||
set -euo pipefail | set -euo pipefail | ||||
# Build Cashtab as a Chrome/Brave browser extension | # Build Cashtab as a Chrome/Brave browser extension | ||||
# Create a working directory for stashing non-extension files | # Create a working directory for stashing non-extension files | ||||
WORKDIR=$(mktemp -d) | WORKDIR=$(mktemp -d) | ||||
echo Using workdir ${WORKDIR} | echo Using workdir ${WORKDIR} | ||||
# Delete workdir on script finish | # Delete workdir on script finish | ||||
function cleanup { | function cleanup { | ||||
# Replace original web files | |||||
echo 'Replacing original web files' | |||||
rm src/assets/popout.svg | |||||
rm public/manifest.json | |||||
rm src/components/App.js | |||||
rm src/components/App.css | |||||
# Note, src/assets/popout.svg does not need to be replaced, not used by web app | |||||
mv ${WORKDIR}/manifest.json public/ | |||||
mv ${WORKDIR}/App.js src/components/ | |||||
mv ${WORKDIR}/App.css src/components/ | |||||
echo 'Web files replaced' | |||||
echo Deleting workdir ${WORKDIR} | echo Deleting workdir ${WORKDIR} | ||||
rm -rf "${WORKDIR}" | rm -rf "${WORKDIR}" | ||||
} | } | ||||
trap cleanup EXIT | trap cleanup EXIT | ||||
# Stash web files that require extension changes in workdir | # Stash web files that require extension changes in workdir | ||||
mv public/manifest.json ${WORKDIR} | mv public/manifest.json ${WORKDIR} | ||||
mv src/components/App.js ${WORKDIR} | mv src/components/App.js ${WORKDIR} | ||||
Show All 23 Lines | |||||
# Browserify contentscript.js and background.js to pull in their imports | # Browserify contentscript.js and background.js to pull in their imports | ||||
browserify extension/src/contentscript.js -o extension/dist/contentscript.js | browserify extension/src/contentscript.js -o extension/dist/contentscript.js | ||||
browserify extension/src/background.js -o extension/dist/background.js | browserify extension/src/background.js -o extension/dist/background.js | ||||
# Delete extension build from build/ folder (reserved for web app builds) | # Delete extension build from build/ folder (reserved for web app builds) | ||||
rm -Rf build | rm -Rf build | ||||
# Replace original web files | echo 'Extension built!' | ||||
rm src/assets/popout.svg | No newline at end of file | ||||
rm public/manifest.json | |||||
rm src/components/App.js | |||||
rm src/components/App.css | |||||
# Note, src/assets/popout.svg does not need to be replaced, not used by web app | |||||
mv ${WORKDIR}/manifest.json public/ | |||||
mv ${WORKDIR}/App.js src/components/ | |||||
mv ${WORKDIR}/App.css src/components/ | |||||
echo 'Extension built and web files replaced!' | |||||
No newline at end of file |