Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9432ae0

Browse filesBrowse files
tbranyenJohn Haley
authored andcommitted
Adds in a BUILD_ONLY environment variable
By default the module will attempt to install from a prebuilt binary from S3. If this fails it will attempt a native compile. For our continuous integration and local development we'll always run with `BUILD_ONLY=true`.
1 parent 0a5632c commit 9432ae0
Copy full SHA for 9432ae0

File tree

Expand file treeCollapse file tree

7 files changed

+47
-41
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

7 files changed

+47
-41
lines changed
Open diff view settings
Collapse file

‎.travis.yml‎

Copy file name to clipboardExpand all lines: .travis.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ before_install:
1414
export CXX='g++-4.8';
1515
fi
1616
- "export JOBS=4"
17-
- npm install
17+
- BUILD_ONLY=true npm install
1818
# This is a random private key used purely for testing.
1919
before_script:
2020
- echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
Collapse file

‎appveyor.yml‎

Copy file name to clipboardExpand all lines: appveyor.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ install:
2727
- cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
2828
- cmd: SET PATH=c:\python27;%PATH%
2929
- cmd: SET JOBS=4
30+
- cmd: SET BUILD_ONLY=true
3031
- cmd: SET GIT_SSH=c:\projects\nodegit\vendor\plink.exe
3132
- ps: Start-Process c:\projects\nodegit\vendor\pageant.exe c:\projects\nodegit\vendor\private.ppk
3233
- cmd: npm install -g node-gyp
Collapse file

‎generate/index.js‎

Copy file name to clipboardExpand all lines: generate/index.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ fse.remove(path.resolve(__dirname, "../src")).then(function() {
100100
}
101101
}
102102
catch (e) {
103-
console.log(e);
103+
if (process.env.BUILD_ONLY) {
104+
console.log(e);
105+
}
104106
}
105107
});
106108

Collapse file

‎generate/setup.js‎

Copy file name to clipboardExpand all lines: generate/setup.js
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ libgit2.types.forEach(function(current) {
5858
var previous = "";
5959
enums = _(enums).sortBy("name").reduce(function(enumMemo, enumerable) {
6060
if (previous == enumerable.typeName) {
61-
console.log('WARNING: duplicate definition for enum ' + enumerable.typeName +
62-
". skipped.");
61+
if (process.env.BUILD_ONLY) {
62+
console.warn('Duplicate definition for enum ' + enumerable.typeName +
63+
". skipped.");
64+
}
6365
}
6466
else if (!enumerable.fields) {
65-
console.log('WARNING: incomplete definition for enum ' + enumerable.typeName +
66-
". skipped.");
67+
if (process.env.BUILD_ONLY) {
68+
console.warn('Incomplete definition for enum ' + enumerable.typeName +
69+
". skipped.");
70+
}
6771
}
6872
else {
6973
enumMemo[enumerable.typeName] = {
Collapse file

‎generate/utils.js‎

Copy file name to clipboardExpand all lines: generate/utils.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ var Utils = {
136136
_.merge(field, callbackDefs[field.type]);
137137
}
138138
else {
139-
console.log("WARNING: Couldn't find callback definition for " + field.type);
139+
if (process.env.BUILD_ONLY) {
140+
console.warn("Couldn't find callback definition for " + field.type);
141+
}
140142
}
141143
},
142144

Collapse file

‎install.js‎

Copy file name to clipboardExpand all lines: install.js
+30-33Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ var which = require("which");
1010
var rimraf = require("rimraf");
1111
var NODE_VERSION = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
1212

13-
// If the build only flag is set
14-
var buildOnly = process.argv.indexOf("--build-only") > -1;
15-
16-
if (buildOnly) {
17-
console.log("buildOnly");
18-
return;
19-
}
13+
// If the build only flag is set.
14+
var buildOnly = process.env.BUILD_ONLY;
2015

2116
// This will take in an object and find any matching keys in the environment
2217
// to use as overrides.
@@ -71,13 +66,34 @@ if (NODE_VERSION === 0.1) {
7166
pkg.http_parser = pkg.http_parser["0.10"];
7267
}
7368

74-
// Ensure all dependencies are available.
75-
var dependencies = Q.allSettled([
76-
// This will prioritize `python2` over `python`, because we always want to
77-
// work with Python 2.* if it"s available.
78-
Q.nfcall(which, "python2"),
79-
Q.nfcall(which, "python")
80-
])
69+
// Attempt to fallback on a prebuilt binary.
70+
function fetchPrebuilt() {
71+
if (!buildOnly) {
72+
console.info("[nodegit] Fetching binary from S3.");
73+
74+
// Using the node-pre-gyp module, attempt to fetch a compatible build.
75+
return Q.nfcall(exec, "node-pre-gyp install");
76+
}
77+
78+
throw new Error("Build only");
79+
}
80+
81+
// Attempt to fetch prebuilt binary.
82+
Q.ninvoke(fs, "mkdir", paths.release).then(fetchPrebuilt, fetchPrebuilt)
83+
84+
.fail(function() {
85+
if (!buildOnly) {
86+
console.info("[nodegit] Failed to install prebuilt, attempting compile.");
87+
}
88+
89+
// Ensure all dependencies are available.
90+
return Q.allSettled([
91+
// This will prioritize `python2` over `python`, because we always want to
92+
// work with Python 2.* if it"s available.
93+
Q.nfcall(which, "python2"),
94+
Q.nfcall(which, "python")
95+
])
96+
})
8197

8298
// Determine if all the dependency requirements are met.
8399
.then(function(results) {
@@ -226,25 +242,6 @@ var dependencies = Q.allSettled([
226242
});
227243
})
228244

229-
// Attempt to fallback on a prebuilt binary.
230-
.fail(function(message) {
231-
console.info("[nodegit] Failed to build nodegit.");
232-
console.info("[nodegit] Attempting to fallback on a prebuilt binary.");
233-
234-
console.log(message.stack);
235-
236-
function fetchPrebuilt() {
237-
console.info("[nodegit] Fetching binary from S3.");
238-
239-
// Using the node-pre-gyp module, attempt to fetch a compatible build.
240-
return Q.nfcall(exec, "node-pre-gyp install");
241-
}
242-
243-
// Attempt to fetch prebuilt binary.
244-
return Q.ninvoke(fs, "mkdir", paths.release)
245-
.then(fetchPrebuilt, fetchPrebuilt);
246-
})
247-
248245
// Display a warning message about failing to build native node module.
249246
.fail(function(message) {
250247
console.info("[nodegit] Failed to build and install nodegit.");
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@
9696
"publish": "node-pre-gyp package && node-pre-gyp publish",
9797
"generate": "node generate/setup && node generate",
9898
"install": "npm run generate && node install",
99-
"rebuild": "npm run generate && node-gyp configure build"
99+
"rebuild": "BUILD_ONLY=true npm run generate && node-gyp configure build"
100100
}
101101
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.