From 02c2f8172a3456bfae1a560ba4c9ee48673a60dc Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 13 Jul 2015 01:23:14 +0100 Subject: Use spawn instead of exec-sync for cake package exec-sync fails to build for some environments and architectures (including mine). As spawn is already necessary for building, we know it will be available, and so can use that via a callback chain to run the packaging tasks. --- Cakefile | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Cakefile b/Cakefile index ffd8308b..514c67e1 100644 --- a/Cakefile +++ b/Cakefile @@ -15,6 +15,14 @@ spawn = (procName, optArray, silent=false) -> proc.stderr.on 'data', (data) -> process.stderr.write data proc +spawnMultiple = (spawnDetailsArray, callback) -> + return callback?() if spawnDetailsArray.length == 0 + {procName, optArray, silent} = spawnDetailsArray.shift() + process = spawn procName, optArray, silent + process.on 'exit', (returnCode) -> + if returnCode == 0 + spawnMultiple spawnDetailsArray, callback + optArrayFromDict = (opts) -> result = [] for key, value of opts @@ -56,24 +64,22 @@ task "autobuild", "continually rebuild coffeescript files using coffee --watch", coffee = spawn "coffee", ["-cw", __dirname] task "package", "Builds a zip file for submission to the Chrome store. The output is in dist/", -> - # To get exec-sync, `npm install exec-sync`. We use this for synchronously executing shell commands. - execSync = require("exec-sync") - vimium_version = JSON.parse(fs.readFileSync("manifest.json").toString())["version"] invoke "build" - execSync "rm -rf dist/vimium" - execSync "mkdir -p dist/vimium" - blacklist = [".*", "*.coffee", "*.md", "reference", "test_harnesses", "tests", "dist", "git_hooks", "CREDITS", "node_modules", "MIT-LICENSE.txt", "Cakefile"] rsyncOptions = [].concat.apply( ["-r", ".", "dist/vimium"], - blacklist.map((item) -> ["--exclude", "'#{item}'"])) - - execSync "rsync " + rsyncOptions.join(" ") - execSync "cd dist && zip -r vimium-#{vimium_version}.zip vimium" + blacklist.map((item) -> ["--exclude", "#{item}"])) + + spawnMultiple [ + {procName: "rm", optArray: ["-rf", "dist/vimium"]}, + {procName: "mkdir", optArray: ["-p", "dist/vimium"]}, + {procName: "rsync", optArray: rsyncOptions}, + {procName: "zip", optArray: ["-r", "dist/vimium-#{vimium_version}.zip", "dist/vimium"]} + ] # This builds a CRX that's distributable outside of the Chrome web store. Is this used by folks who fork # Vimium and want to distribute their fork? -- cgit v1.2.3