diff --git a/_build/build.js b/_build/build.js index 71c65171..6a730eb4 100755 --- a/_build/build.js +++ b/_build/build.js @@ -3,7 +3,6 @@ var FS = require("fs"); var PATH = require("path"); -var Q = require("q"); var Writable = require("stream").Writable; var shell = require('shelljs'); // nicer scripting interface var generateJsdoc = require("./jsdoc/jsdoc"); @@ -17,24 +16,26 @@ var spawn = require("child_process").spawn; * @return {Promise} A promise for the completion of the command. */ var exec = function (command, args, cwd, silent) { - var deferred = Q.defer(); - cwd = cwd || process.cwd(); + var promise = new Promise(function(resolve, reject) { - if (!silent) { - console.log("+", command, args.join(" "), "# in", cwd); - } - var proc = spawn(command, args, { - cwd: cwd, - stdio: silent ? "ignore" : "inherit" - }); - proc.on('exit', function(code) { - if (code !== 0) { - deferred.reject(new Error(command + " " + args.join(" ") + " in " + cwd + " exited with code " + code)); - } else { - deferred.resolve(); + var cwd = cwd || process.cwd(); + + if (!silent) { + console.log("+", command, args.join(" "), "# in", cwd); } + var proc = spawn(command, args, { + cwd: cwd, + stdio: silent ? "ignore" : "inherit" + }); + proc.on('exit', function(code) { + if (code !== 0) { + reject(new Error(command + " " + args.join(" ") + " in " + cwd + " exited with code " + code)); + } else { + resolve(); + } + }); }); - return deferred.promise; + return promise; }; var SOURCE_PATH = PATH.join(__dirname, ".."); @@ -45,7 +46,7 @@ var APPS = { var TEMP_DIR = PATH.join(SOURCE_PATH, "tmp"); function cloneAndMopApps(apps) { - return Q.all(Object.keys(apps).map(function (name) { + return Promise.all(Object.keys(apps).map(function (name) { var repo = apps[name].url; var commit = apps[name].commit || "master"; @@ -106,13 +107,13 @@ function mopHomeExample() { }) .then(function () { // Remove generated files from root - return Q.all(paths.map(function (path) { + return Promise.all(paths.map(function (path) { return exec("rm", ["-r", PATH.join(outPath, path)]); })); }) .then(function () { // Copy generated files back to root - return Q.all(paths.map(function (path) { + return Promise.all(paths.map(function (path) { return exec("cp", ["-r", PATH.join(buildPath, path), PATH.join(outPath, path)]); })); }) @@ -167,7 +168,6 @@ if (require.main === module) { }) .then(function () { console.log("done"); - }) - .done(); + }); }