| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9543011 commit 805edba
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,6 @@ if (require.main === module) { | |||
| 42 | 42 | console.log("nothing to do"); | |
| 43 | 43 | } | |
| 44 | 44 | else { | |
| 45 | - module.exports(); | ||
| 45 | + module.exports().done(); | ||
| 46 | 46 | } | |
| 47 | 47 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,53 +1,52 @@ | |||
| 1 | - var nodePreGypConstructor = require("node-pre-gyp"); | ||
| 2 | - var nodePreGyp = new nodePreGypConstructor.Run(); | ||
| 1 | + var path = require("path"); | ||
| 2 | + | ||
| 3 | 3 | var buildFlags = require("../utils/buildFlags"); | |
| 4 | + var exec = require("../utils/execPromise"); | ||
| 4 | 5 | ||
| 5 | 6 | module.exports = function install() { | |
| 6 | 7 | console.log("[nodegit] Running install script"); | |
| 7 | 8 | ||
| 8 | - // we need to add 2 blank entires to help the parser later. | ||
| 9 | - var argv = ["", "", "install"]; | ||
| 9 | + var nodePreGypCmd = path.join( | ||
| 10 | + __dirname, | ||
| 11 | + "..", | ||
| 12 | + "node_modules", | ||
| 13 | + ".bin", | ||
| 14 | + "node-pre-gyp" | ||
| 15 | + ); | ||
| 16 | + | ||
| 17 | + if (process.platform === "win32") { | ||
| 18 | + nodePreGypCmd += ".cmd"; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + var cmd = [nodePreGypCmd, "install"]; | ||
| 10 | 22 | ||
| 11 | 23 | if (buildFlags.mustBuild) { | |
| 12 | - argv.push("--build-from-source"); | ||
| 24 | + console.info( | ||
| 25 | + "[nodegit] Pre-built download disabled, building from source." | ||
| 26 | + ); | ||
| 27 | + cmd.push("--build-from-source"); | ||
| 13 | 28 | ||
| 14 | 29 | if (buildFlags.debugBuild) { | |
| 15 | - argv.push("--debug"); | ||
| 30 | + console.info("[nodegit] Building debug version."); | ||
| 31 | + cmd.push("--debug"); | ||
| 16 | 32 | } | |
| 17 | 33 | } | |
| 18 | 34 | else { | |
| 19 | - argv.push("--fallback-to-build"); | ||
| 35 | + cmd.push("--fallback-to-build"); | ||
| 20 | 36 | } | |
| 21 | 37 | ||
| 22 | - nodePreGyp.parseArgv(argv); | ||
| 23 | - | ||
| 24 | - function run() { | ||
| 25 | - var command = nodePreGyp.todo.shift(); | ||
| 26 | - if (!command) { | ||
| 27 | - return; | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - nodePreGyp.commands[command.name](command.args, function (err) { | ||
| 31 | - if (err) { | ||
| 32 | - console.error(command.name + " error"); | ||
| 33 | - console.error("stack", err.stack); | ||
| 34 | - console.error("not ok"); | ||
| 35 | - console.log(err.message); | ||
| 36 | - return process.exit(1); | ||
| 37 | - } | ||
| 38 | - var args_array = [].slice.call(arguments, 1); | ||
| 39 | - if (args_array.length) { | ||
| 40 | - console.log.apply(console, args_array); | ||
| 41 | - } | ||
| 42 | - // now run the next command in the queue | ||
| 43 | - process.nextTick(run); | ||
| 38 | + return exec(cmd.join(" ")) | ||
| 39 | + .then(function() { | ||
| 40 | + console.info("[nodegit] Completed installation successfully."); | ||
| 44 | 41 | }); | |
| 45 | - } | ||
| 46 | - | ||
| 47 | - run(); | ||
| 48 | 42 | }; | |
| 49 | 43 | ||
| 50 | 44 | // Called on the command line | |
| 51 | 45 | if (require.main === module) { | |
| 52 | - module.exports(); | ||
| 46 | + module.exports() | ||
| 47 | + .catch(function(e) { | ||
| 48 | + console.error("[nodegit] ERROR - Could not finish install"); | ||
| 49 | + console.error(e); | ||
| 50 | + process.exit(1); | ||
| 51 | + }); | ||
| 53 | 52 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,7 @@ | |||
| 1 | - #!/usr/bin/env node | ||
| 2 | - | ||
| 3 | 1 | var fse = require("fs-extra"); | |
| 4 | 2 | var path = require("path"); | |
| 5 | - var child_process = require("child_process"); | ||
| 3 | + | ||
| 4 | + var exec = require("../utils/execPromise"); | ||
| 6 | 5 | var buildFlags = require("../utils/buildFlags"); | |
| 7 | 6 | ||
| 8 | 7 | var rootPath = path.join(__dirname, ".."); | |
@@ -16,25 +15,37 @@ function printStandardLibError() { | |||
| 16 | 15 | console.log(""); | |
| 17 | 16 | console.log("$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test"); | |
| 18 | 17 | console.log("$ sudo apt-get update"); | |
| 18 | + console.log("$ sudo apt-get install libstdc++-4.9-dev"); | ||
| 19 | 19 | } | |
| 20 | 20 | ||
| 21 | - console.log("$ sudo apt-get install libstdc++-4.9-dev"); | ||
| 22 | - child_process.exec("node dist/nodegit.js", function(error, stdout, stderr) { | ||
| 23 | - if (stderr) { | ||
| 24 | - if (process.pladtform !== "linux" && ~stderr.indexOf("libstdc++")) { | ||
| 25 | - printStandardLibError(); | ||
| 26 | - } | ||
| 21 | + module.exports = function install() { | ||
| 22 | + return exec("node dist/nodegit.js") | ||
| 23 | + .then(function() { | ||
| 24 | + // Is we're using NodeGit from a package manager then let's clean up after | ||
| 25 | + // ourselves when we install successfully. | ||
| 26 | + if (!buildFlags.mustBuild) { | ||
| 27 | + fse.removeSync(path.join(rootPath, "vendor")); | ||
| 28 | + fse.removeSync(path.join(rootPath, "src")); | ||
| 29 | + fse.removeSync(path.join(rootPath, "include")); | ||
| 30 | + fse.removeSync(path.join(rootPath, "build/Release/*.a")); | ||
| 31 | + fse.removeSync(path.join(rootPath, "build/Release/obj.target")); | ||
| 32 | + } | ||
| 33 | + }); | ||
| 34 | + }; | ||
| 27 | 35 | ||
| 28 | - return; | ||
| 29 | - } | ||
| 36 | + // Called on the command line | ||
| 37 | + if (require.main === module) { | ||
| 38 | + module.exports() | ||
| 39 | + .catch(function(e) { | ||
| 40 | + console.error("[nodegit] ERROR - Could not finish postinstall"); | ||
| 30 | 41 | ||
| 31 | - // Is we're using NodeGit from a package manager then let's clean up after | ||
| 32 | - // ourselves when we install successfully. | ||
| 33 | - if (!buildFlags.mustBuild) { | ||
| 34 | - fse.removeSync(path.join(rootPath, "vendor")); | ||
| 35 | - fse.removeSync(path.join(rootPath, "src")); | ||
| 36 | - fse.removeSync(path.join(rootPath, "include")); | ||
| 37 | - fse.removeSync(path.join(rootPath, "build/Release/*.a")); | ||
| 38 | - fse.removeSync(path.join(rootPath, "build/Release/obj.target")); | ||
| 39 | - } | ||
| 40 | - }); | ||
| 42 | + if (process.pladtform !== "linux" && ~e.indexOf("libstdc++")) { | ||
| 43 | + printStandardLibError(); | ||
| 44 | + } | ||
| 45 | + else { | ||
| 46 | + console.error(e); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + process.exit(1); | ||
| 50 | + }); | ||
| 51 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,6 +41,7 @@ | |||
| 41 | 41 | "fs-extra": "~0.26.2", | |
| 42 | 42 | "lodash": "^4.13.1", | |
| 43 | 43 | "nan": "^2.2.0", | |
| 44 | + "node-gyp": "^3.3.1", | ||
| 44 | 45 | "node-pre-gyp": "~0.6.15", | |
| 45 | 46 | "promisify-node": "~0.3.0" | |
| 46 | 47 | }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments