How to pack a Chrome extension on Mac OSX with commandline?
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --pack-extension...
A complete example to run on the shell:
"/Users/varr/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --pack-extension="/Users/varr/Dropbox/Code/Projects/Bookmark Express/src"
Things to note:
- Chrome will not display any output of success or failure but it will return an exit code
- Your shell (ex. oh-my-zsh) may display exit codes so you can have an idea there
- Chrome will generate two files, the
.crx
and a.pem
To automate this, I used Geb (and Groovy). In GebConfig.groovy
, I tried using:
def chromePath = "/Users/varr/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"def packExtensionSwitch='--pack-extension="/Users/varr/Dropbox/Code/Projects/Bookmark Express/src"'ProcessBuilder packExtension = new ProcessBuilder(chromePath, packExtensionSwitch)Process process = packExtension.start()
But this returned an exit code 21 every time and no files were generated. I finalized my approach with:
def packageExtensionScript = '/Users/varr/package.sh'ProcessBuilder packExtension = new ProcessBuilder(packageExtensionScript)Process process = packExtension.start()
To finish it up, I made package.sh
a one-line script with the command to run and it all worked!