| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,11 @@ | |||
| 1 | 1 | var promisify = require("promisify-node"); | |
| 2 | 2 | var path = require("path"); | |
| 3 | 3 | var fs = require("fs"); | |
| 4 | - | ||
| 4 | + var cp = require("child_process"); | ||
| 5 | 5 | var prepareForBuild = require("./prepareForBuild"); | |
| 6 | 6 | ||
| 7 | 7 | var exec = promisify(function(command, opts, callback) { | |
| 8 | - return require("child_process").exec(command, opts, callback); | ||
| 8 | + return cp.exec(command, opts, callback); | ||
| 9 | 9 | }); | |
| 10 | 10 | ||
| 11 | 11 | var fromRegistry; | |
@@ -52,7 +52,9 @@ function installPrebuilt() { | |||
| 52 | 52 | ||
| 53 | 53 | function pathForTool(name) { | |
| 54 | 54 | var toolPath = path.resolve(".", "node_modules", ".bin", name); | |
| 55 | - toolPath = "\"" + toolPath + "\""; | ||
| 55 | + if (process.platform == "win32") { | ||
| 56 | + toolPath += ".cmd"; | ||
| 57 | + } | ||
| 56 | 58 | return toolPath; | |
| 57 | 59 | } | |
| 58 | 60 | ||
@@ -72,7 +74,8 @@ function build() { | |||
| 72 | 74 | var opts = { | |
| 73 | 75 | cwd: ".", | |
| 74 | 76 | maxBuffer: Number.MAX_VALUE, | |
| 75 | - env: process.env | ||
| 77 | + env: process.env, | ||
| 78 | + stdio: "inherit" | ||
| 76 | 79 | }; | |
| 77 | 80 | ||
| 78 | 81 | var builder = "node-gyp"; | |
@@ -104,26 +107,27 @@ function build() { | |||
| 104 | 107 | ||
| 105 | 108 | opts.env.HOME = path.join(home, ".nodegit-gyp"); | |
| 106 | 109 | ||
| 107 | - var cmd = [ | ||
| 108 | - pathForTool(builder), | ||
| 110 | + var cmd = pathForTool(builder); | ||
| 111 | + var args = [ | ||
| 109 | 112 | "rebuild", | |
| 110 | 113 | debug, | |
| 111 | 114 | target, | |
| 112 | 115 | distUrl | |
| 113 | 116 | ] | |
| 114 | 117 | .join(" ") | |
| 115 | - .trim(); | ||
| 116 | - | ||
| 117 | - return exec(cmd, opts) | ||
| 118 | - .then(function() { | ||
| 119 | - console.info("[nodegit] Compilation complete."); | ||
| 120 | - console.info("[nodegit] Completed installation successfully."); | ||
| 121 | - process.exitCode = 0; | ||
| 122 | - }, | ||
| 123 | - function(err, stderr) { | ||
| 124 | - console.error(err); | ||
| 125 | - console.error(stderr); | ||
| 118 | + .trim() | ||
| 119 | + .split(" "); | ||
| 120 | + return new Promise(function(resolve, reject) { | ||
| 121 | + var child = cp.spawn(cmd, args, opts); | ||
| 122 | + child.on("close", function(code) { | ||
| 123 | + console.log(code); | ||
| 124 | + if (code) { | ||
| 125 | + reject(code); | ||
| 126 | 126 | process.exitCode = 13; | |
| 127 | 127 | } | |
| 128 | - ); | ||
| 128 | + else { | ||
| 129 | + resolve(); | ||
| 130 | + } | ||
| 131 | + }) | ||
| 132 | + }); | ||
| 129 | 133 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments