| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ var Promise = require("nodegit-promise"); | |||
| 7 | 7 | var promisify = require("promisify-node"); | |
| 8 | 8 | var request = require("request"); | |
| 9 | 9 | var fse = promisify(require("fs-extra")); | |
| 10 | + var findParentDir = promisify(require('find-parent-dir')); | ||
| 10 | 11 | fse.ensureDir = promisify(fse.ensureDir, function() { return true; }); | |
| 11 | 12 | ||
| 12 | 13 | var exec = promisify(function(command, opts, callback) { | |
@@ -17,6 +18,7 @@ var NODE_VERSION = Number(process.version.match(/^v(\d+\.\d+)/)[1]); | |||
| 17 | 18 | ||
| 18 | 19 | // If the build only flag is set. | |
| 19 | 20 | var buildOnly = process.env.BUILD_ONLY; | |
| 21 | + var nodeWebkit = false; | ||
| 20 | 22 | ||
| 21 | 23 | // This will take in an object and find any matching keys in the environment | |
| 22 | 24 | // to use as overrides. | |
@@ -72,23 +74,31 @@ if (NODE_VERSION === 0.1) { | |||
| 72 | 74 | } | |
| 73 | 75 | ||
| 74 | 76 | fse.ensureDir(path.resolve(__dirname, paths.release)) | |
| 77 | + .then(detectNodeWebkit.call(null, __dirname)) | ||
| 75 | 78 | .then(fetch) | |
| 76 | 79 | .then(finish, compile) | |
| 77 | 80 | .done() | |
| 78 | 81 | ||
| 79 | 82 | function fetch() { | |
| 80 | - if (!buildOnly) { | ||
| 81 | - console.info("[nodegit] Fetching binary from S3."); | ||
| 83 | + console.info("[nodegit] Fetching binary from S3."); | ||
| 82 | 84 | ||
| 83 | - // Using the node-pre-gyp module, attempt to fetch a compatible build. | ||
| 84 | - return exec("node-pre-gyp install"); | ||
| 85 | + if (nodeWebkit) { | ||
| 86 | + throw new Error("Must build for node-webkit"); | ||
| 85 | 87 | } | |
| 86 | 88 | ||
| 87 | - throw new Error("BUILD_ONLY is set to true, no fetching allowed."); | ||
| 89 | + if (buildOnly) { | ||
| 90 | + throw new Error("BUILD_ONLY is set to true, no fetching allowed."); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + // Using the node-pre-gyp module, attempt to fetch a compatible build. | ||
| 94 | + return exec("node-pre-gyp install"); | ||
| 88 | 95 | } | |
| 89 | 96 | ||
| 90 | - function compile() { | ||
| 91 | - if (!buildOnly) { | ||
| 97 | + function compile(err) { | ||
| 98 | + if (buildOnly || nodeWebkit) { | ||
| 99 | + console.info("[nodegit] " + err.message); | ||
| 100 | + } | ||
| 101 | + else { | ||
| 92 | 102 | console.info("[nodegit] Failed to install prebuilt, attempting compile."); | |
| 93 | 103 | } | |
| 94 | 104 | ||
@@ -173,11 +183,21 @@ function getVendorLib(name, url) { | |||
| 173 | 183 | ||
| 174 | 184 | function buildNative() { | |
| 175 | 185 | return exec("cd " + __dirname).then(function() { | |
| 176 | - console.info("[nodegit] Building native node module."); | ||
| 177 | - var pythonFlag = " --python \"" + pythonPath + "\""; | ||
| 178 | - var cmd = path.resolve(systemPath([ | ||
| 179 | - ".", "node_modules", ".bin", "node-gyp clean configure build" + pythonFlag | ||
| 180 | - ])); | ||
| 186 | + if (nodeWebkit) { | ||
| 187 | + console.info("[nodegit] Building native node-webkit module."); | ||
| 188 | + } | ||
| 189 | + else { | ||
| 190 | + console.info("[nodegit] Building native node module."); | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + var builder = nodeWebkit ? "nw-gyp" : "node-gyp"; | ||
| 194 | + | ||
| 195 | + var cmd = path.resolve(".", "node_modules", ".bin", builder) | ||
| 196 | + + " clean configure " | ||
| 197 | + + (nodeWebkit ? "--target=\"" + nodeWebkit + "\"": "") | ||
| 198 | + + " build " + pythonFlag | ||
| 199 | + + "--python \"" + pythonPath + "\"" | ||
| 200 | + | ||
| 181 | 201 | var opts = { | |
| 182 | 202 | cwd: __dirname, | |
| 183 | 203 | maxBuffer: Number.MAX_VALUE | |
@@ -186,6 +206,20 @@ function buildNative() { | |||
| 186 | 206 | }) | |
| 187 | 207 | } | |
| 188 | 208 | ||
| 209 | + function detectNodeWebkit(directory) { | ||
| 210 | + if (directory) { | ||
| 211 | + var pkg = require(path.resolve(directory, "package.json")); | ||
| 212 | + | ||
| 213 | + nodeWebkit = pkg.engines && pkg.engines["node-webkit"]; | ||
| 214 | + | ||
| 215 | + return findParentDir(path.resolve(directory, ".."), "package.json") | ||
| 216 | + .then(detectNodeWebkit); | ||
| 217 | + } | ||
| 218 | + else { | ||
| 219 | + return Promise.resolve(); | ||
| 220 | + } | ||
| 221 | + } | ||
| 222 | + | ||
| 189 | 223 | function finish() { | |
| 190 | 224 | console.info("[nodegit] Completed installation successfully."); | |
| 191 | 225 | return Promise.resolve().done(); | |
@@ -194,6 +228,6 @@ function finish() { | |||
| 194 | 228 | function fail(message) { | |
| 195 | 229 | console.info("[nodegit] Failed to build and install nodegit."); | |
| 196 | 230 | console.info(message.message); | |
| 197 | - //console.info(message.stack); | ||
| 231 | + | ||
| 198 | 232 | return Promise.resolve().done(); | |
| 199 | 233 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,16 +61,18 @@ | |||
| 61 | 61 | ], | |
| 62 | 62 | "dependencies": { | |
| 63 | 63 | "combyne": "~0.6.2", | |
| 64 | + "find-parent-dir": "^0.3.0", | ||
| 64 | 65 | "fs-extra": "^0.12.0", | |
| 65 | - "lodash": "^2.4.1", | ||
| 66 | 66 | "istanbul": "~0.3.2", | |
| 67 | 67 | "js-beautify": "^1.5.4", | |
| 68 | 68 | "jshint": "~2.5.6", | |
| 69 | + "lodash": "^2.4.1", | ||
| 69 | 70 | "mocha": "~1.21.4", | |
| 70 | 71 | "nan": "~1.3.0", | |
| 71 | 72 | "node-gyp": "~1.0.2", | |
| 72 | 73 | "node-pre-gyp": "~0.5.27", | |
| 73 | 74 | "nodegit-promise": "~1.0.0", | |
| 75 | + "nw-gyp": "^0.12.4", | ||
| 74 | 76 | "promisify-node": "~0.1.2", | |
| 75 | 77 | "request": "~2.45.0", | |
| 76 | 78 | "tar": "~1.0.1" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments