forked from wighawag/jolly-roger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.setup.js
62 lines (57 loc) · 1.11 KB
/
.setup.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env node
const fs = require('fs');
function copyFromDefault(p) {
if (!fs.existsSync(p)) {
const defaultFile = `${p}.default`;
if (fs.existsSync(defaultFile)) {
fs.copyFileSync(`${p}.default`, p);
}
}
}
function writeIfNotExists(p, content) {
if (!fs.existsSync(p)) {
fs.writeFileSync(p, content);
}
}
['{{=_.paramCase(it.name)}}.code-workspace', '.env', '.env.production', '.env.staging'].map(
copyFromDefault
);
switch (process.platform) {
case 'win32':
writeIfNotExists(
'.newsh.json',
`
{
"terminalApp": "cmd"
}
`
);
break;
case 'linux':
writeIfNotExists(
'.newsh.json',
`
{
"terminalApp": "xterm"
}
`
);
break;
}
const execSync = require('child_process').execSync
function npmInstall (dir) {
console.log(`INSTALLING ${dir}...`)
let exitCode = 0;
try {
execSync('npm install', { cwd: dir, stdio: 'inherit'})
} catch (err) {
exitCode = err.status
}
if (exitCode) {
process.exit(exitCode);
}
}
npmInstall('common-lib');
npmInstall('contracts');
npmInstall('subgraph');
npmInstall('web');