Skip to content

Commit 3fe3b98

Browse files
maxkorpJohn Haley
authored andcommitted
Fix npm registry detection
1 parent adb5bea commit 3fe3b98

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

.didntcomefromthenpmregistry

Whitespace-only changes.

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
.jshintrc
1616
.travis.yml
1717
appveyor.yml
18-
.didntcomefromthenpmregistry
1918

2019
*.vcxproj
2120
*.filters

lifecycleScripts/install.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ var exec = promisify(function(command, opts, callback) {
88
return require("child_process").exec(command, opts, callback);
99
});
1010

11-
var local = path.join.bind(path, __dirname);
11+
var fromRegistry;
12+
try {
13+
fs.statSync(path.join(__dirname, "..", "include"));
14+
fs.statSync(path.join(__dirname, "..", "src"));
15+
fromRegistry = true;
16+
}
17+
catch(e) {
18+
fromRegistry = false;
19+
}
1220

13-
if (fs.existsSync(local("../.didntcomefromthenpmregistry"))) {
21+
if (fromRegistry) {
22+
console.info("[nodegit] Local install, no fetching allowed.");
1423
return prepareAndBuild();
1524
}
1625
if (process.env.BUILD_DEBUG) {
@@ -41,14 +50,12 @@ function installPrebuilt() {
4150
);
4251
}
4352

44-
4553
function pathForTool(name) {
4654
var toolPath = path.resolve(".", "node_modules", ".bin", name);
4755
toolPath = toolPath.replace(/\s/g, "\\$&");
4856
return toolPath;
4957
}
5058

51-
5259
function prepareAndBuild() {
5360
console.info("[nodegit] Regenerating and configuring code");
5461
return prepareForBuild()
@@ -73,8 +80,7 @@ function build() {
7380

7481
opts.env.HOME = path.join(home, ".nodegit-gyp");
7582

76-
var builder = pathForTool("node-gyp");
77-
var cmd = [builder, "rebuild", debug].join(" ").trim();
83+
var cmd = [pathForTool("node-gyp"), "rebuild", debug].join(" ").trim();
7884

7985
return exec(cmd, opts)
8086
.then(function() {

0 commit comments

Comments
 (0)