postinstall.js 2.0 KB
Newer Older
F
f111fei 已提交
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

J
Joao Moreno 已提交
6
const cp = require('child_process');
J
Joao Moreno 已提交
7
const path = require('path');
J
Joao Moreno 已提交
8
const fs = require('fs');
J
Joao Moreno 已提交
9
const yarn = process.platform === 'win32' ? 'yarn.cmd' : 'yarn';
F
f111fei 已提交
10

J
Joao Moreno 已提交
11
function yarnInstall(location, opts) {
J
Joao Moreno 已提交
12 13 14 15
	opts = opts || {};
	opts.cwd = location;
	opts.stdio = 'inherit';

J
Joao Moreno 已提交
16
	const result = cp.spawnSync(yarn, ['install'], opts);
17 18 19 20 21 22

	if (result.error || result.status !== 0) {
		process.exit(1);
	}
}

J
Joao Moreno 已提交
23
yarnInstall('extensions'); // node modules shared by all extensions
24

J
Joao Moreno 已提交
25 26 27 28
const extensions = [
	'vscode-api-tests',
	'vscode-colorize-tests',
	'json',
29
	'configuration-editing',
30
	'extension-editing',
K
kieferrm 已提交
31
	'markdown',
J
Joao Moreno 已提交
32
	'typescript',
J
Joao Moreno 已提交
33
	'php',
M
Martin Aeschlimann 已提交
34
	'javascript',
35
	'package-json',
M
Martin Aeschlimann 已提交
36
	'css',
J
Joao Moreno 已提交
37
	'html',
38
	'git',
39
	'gulp',
40
	'grunt',
41
	'jake',
42
	'merge-conflict',
43 44 45
	'emmet',
	'npm',
	'jake'
J
Joao Moreno 已提交
46
];
F
f111fei 已提交
47

J
Joao Moreno 已提交
48
extensions.forEach(extension => yarnInstall(`extensions/${extension}`));
49

J
Joao Moreno 已提交
50
function yarnInstallBuildDependencies() {
J
Joao Moreno 已提交
51
	// make sure we install the deps of build/lib/watch for the system installed
J
Joao Moreno 已提交
52
	// node, since that is the driver of gulp
E
Erich Gamma 已提交
53
	//@ts-ignore review
J
Joao Moreno 已提交
54
	const env = Object.assign({}, process.env);
J
Joao Moreno 已提交
55 56
	const watchPath = path.join(path.dirname(__dirname), 'lib', 'watch');
	const yarnrcPath = path.join(watchPath, '.yarnrc');
J
Joao Moreno 已提交
57

J
Joao Moreno 已提交
58 59 60
	const disturl = 'https://nodejs.org/download/release';
	const target = process.versions.node;
	const runtime = 'node';
J
Joao Moreno 已提交
61

J
Joao Moreno 已提交
62 63 64 65 66 67
	const yarnrc = `disturl "${disturl}"
target "${target}"
runtime "${runtime}"`;

	fs.writeFileSync(yarnrcPath, yarnrc, 'utf8');
	yarnInstall(watchPath, { env });
J
Joao Moreno 已提交
68 69
}

J
Joao Moreno 已提交
70 71 72
yarnInstall(`build`); // node modules required for build
yarnInstall('test/smoke'); // node modules required for smoketest
yarnInstallBuildDependencies(); // node modules for watching, specific to host node version, not electron