Skip to content

Commit 0841799

Browse files
committed
add support for atom-shell
1 parent c82343c commit 0841799

File tree

3 files changed

+43
-19
lines changed

3 files changed

+43
-19
lines changed

lifecycleScripts/clean.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ npm.load({
6262

6363
var modulesToPrune = [
6464
"for-node-webkit",
65+
"which-native-nodish",
6566
"fs-extra",
6667
"node-pre-gyp",
6768
"npm"

lifecycleScripts/install.js

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,28 @@ var fs = require("fs");
66
var local = path.join.bind(path, __dirname);
77

88
var checkPrepared = require(local("checkPrepared"));
9-
var forNodeWebkit = require("for-node-webkit");
9+
var whichNativeNodish = require("which-native-nodish");
1010
var prepareForBuild = require(local("prepareForBuild"));
1111

1212
var exec = promisify(function(command, opts, callback) {
1313
return require("child_process").exec(command, opts, callback);
1414
});
15+
var nwVersion = null;
16+
var asVersion = null;
1517

16-
return forNodeWebkit(local(".."))
18+
return whichNativeNodish(local(".."))
1719
.then(function(results) {
18-
return results.nwVersion;
20+
nwVersion = results.nwVersion;
21+
asVersion = results.asVersion;
1922
})
20-
.then(function(nodeWebkitVersion) {
21-
if (nodeWebkitVersion) {
22-
console.info("[nodegit] Must build for node-webkit");
23-
return checkAndBuild(nodeWebkitVersion);
23+
.then(function() {
24+
if (nwVersion) {
25+
console.info("[nodegit] Must build for node-webkit/nw.js");
26+
return checkAndBuild();
27+
}
28+
else if (asVersion) {
29+
console.info("[nodegit] Must build for atom-shell");
30+
return checkAndBuild();
2431
}
2532
if (fs.existsSync(local("../.didntcomefromthenpmregistry"))) {
2633
return checkAndBuild();
@@ -48,7 +55,7 @@ return forNodeWebkit(local(".."))
4855
});
4956

5057

51-
function checkAndBuild(nwVersion) {
58+
function checkAndBuild() {
5259
console.info("[nodegit] Making sure dependencies are available and native " +
5360
"code is generated");
5461

@@ -64,11 +71,11 @@ function checkAndBuild(nwVersion) {
6471
}
6572
})
6673
.then(function() {
67-
return build(nwVersion);
74+
return build();
6875
});
6976
}
7077

71-
function build(nwVersion) {
78+
function build() {
7279
console.info("[nodegit] Everything is ready to go, attempting compilation");
7380
if (nwVersion) {
7481
console.info("[nodegit] Building native node-webkit module.");
@@ -82,14 +89,30 @@ function build(nwVersion) {
8289
maxBuffer: Number.MAX_VALUE
8390
};
8491

85-
var builder = nwVersion ? "nw-gyp" : "node-gyp";
86-
var target = (nwVersion ? "--target=\"" + nwVersion + "\"": "");
92+
var prefix = "";
93+
var target = "";
8794
var debug = (process.env.BUILD_DEBUG ? " --debug" : "");
88-
var cmd = path.resolve(".", "node_modules", ".bin", builder) +
89-
" clean configure" +
90-
debug +
91-
target +
92-
" build";
95+
var builder = "node-gyp";
96+
var distUrl = "";
97+
98+
if (asVersion) {
99+
prefix = (process.platform == "win32" ?
100+
"SET HOME=\"~/.atom-shell-gyp\" && " :
101+
"HOME=~/.atom-shell-gyp");
102+
103+
target = "--target=" + asVersion;
104+
105+
distUrl = "--dist-url=https://gh-contractor-zcbenz.s3." +
106+
"amazonaws.com/atom-shell/dist";
107+
}
108+
else if (nwVersion) {
109+
builder = "nw-gyp";
110+
target = "--target=" + nwVersion;
111+
}
112+
113+
builder = path.resolve(".", "node_modules", ".bin", builder);
114+
var cmd = [prefix, builder, "rebuild", target, debug, distUrl]
115+
.join(" ").trim();
93116

94117
return exec(cmd, opts)
95118
.then(function() {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454
"node-pre-gyp"
5555
],
5656
"dependencies": {
57-
"for-node-webkit": "0.0.2",
5857
"fs-extra": "~0.15.0",
5958
"node-pre-gyp": "~0.6.1",
6059
"nodegit-promise": "~1.0.0",
6160
"npm": "^2.1.18",
62-
"promisify-node": "~0.1.2"
61+
"promisify-node": "~0.1.2",
62+
"which-native-nodish": "^1.0.3"
6363
},
6464
"devDependencies": {
6565
"mocha": "~2.1.0",

0 commit comments

Comments
 (0)