Skip to content

Commit f7aac1b

Browse files
committed
1 parent ca59971 commit f7aac1b

2 files changed

Lines changed: 22 additions & 24 deletions

File tree

build/npm/postinstall.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
const cp = require('child_process');
7+
const path = require('path');
78
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
89

9-
function npmInstall(location) {
10-
const result = cp.spawnSync(npm, ['install'], {
11-
cwd: location ,
12-
stdio: 'inherit'
13-
});
10+
function npmInstall(location, opts) {
11+
opts = opts || {};
12+
opts.cwd = location;
13+
opts.stdio = 'inherit';
14+
15+
const result = cp.spawnSync(npm, ['install'], opts);
1416

1517
if (result.error || result.status !== 0) {
1618
process.exit(1);
@@ -43,4 +45,17 @@ const extensions = [
4345

4446
extensions.forEach(extension => npmInstall(`extensions/${extension}`));
4547

46-
npmInstall(`build`); // node modules required for build
48+
function npmInstallBuildDependencies() {
49+
// make sure we install gulp watch for the system installed
50+
// node, since that is the driver of gulp
51+
const env = Object.assign({}, process.env);
52+
53+
delete env['npm_config_disturl'];
54+
delete env['npm_config_target'];
55+
delete env['npm_config_runtime'];
56+
57+
npmInstall(path.join(path.dirname(__dirname), 'lib', 'watch'), { env });
58+
}
59+
60+
npmInstall(`build`); // node modules required for build
61+
npmInstallBuildDependencies(); // node modules for watching, specific to host node version, not electron

build/npm/preinstall.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
const path = require('path');
7-
const cp = require('child_process');
8-
96
if (process.env['npm_config_disturl'] !== 'https://atom.io/download/electron') {
107
console.error("You can't use plain npm to install Code's dependencies.");
118
console.error(
@@ -15,18 +12,4 @@ if (process.env['npm_config_disturl'] !== 'https://atom.io/download/electron') {
1512
);
1613

1714
process.exit(1);
18-
}
19-
20-
// make sure we install gulp watch for the system installed
21-
// node, since that is the driver of gulp
22-
const env = Object.assign({}, process.env);
23-
24-
delete env['npm_config_disturl'];
25-
delete env['npm_config_target'];
26-
delete env['npm_config_runtime'];
27-
28-
cp.spawnSync('npm', ['install'], {
29-
cwd: path.join(path.dirname(__dirname), 'lib', 'watch'),
30-
stdio: 'inherit',
31-
env
32-
});
15+
}

0 commit comments

Comments
 (0)