-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathinstall
More file actions
executable file
·39 lines (31 loc) · 1.07 KB
/
install
File metadata and controls
executable file
·39 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
var spawnSync = require('child_process').spawnSync;
var fs = require('fs');
function loadJson(fileName) {
if (fs.existsSync(fileName)) {
var text = fs.readFileSync(fileName, 'utf-8');
return JSON.parse(text);
}
}
function saveJson(fileName, content) {
var text = JSON.stringify(content, null, 2);
fs.writeFileSync(fileName, text);
}
var packages = loadJson('./package.json');
var status = loadJson('./.status.json') || {};
function installPackages(packages) {
for (var name in packages) {
if (fs.existsSync('./node_modules/' + name) && status[name]) {
continue;
}
var version = packages[name];
var extension = process.platform === 'win32' ? '.cmd' : '';
var result = spawnSync('cnpm' + extension, ['install', '--verb', name + '@' + version], {stdio: 'inherit'});
status[name] = !result.error;
saveJson('./.status.json', status);
}
}
installPackages(packages.dependencies);
installPackages(packages.devDependencies);
spawnSync('cnpm', ['link'], {stdio: 'inherit'});
spawnSync('fj', ['help'], {stdio: 'inherit'});