-
Notifications
You must be signed in to change notification settings - Fork 1
/
link.js
35 lines (33 loc) · 1.03 KB
/
link.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
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const fs = require('fs')
const packages = []
const execAndPrint = (cmd) => {
console.log(cmd)
return exec(cmd)
}
fs.readdir('.', async (err, files) => {
files.forEach(file => {
if (file.match(/^clusterduck(-[\w+\-_]+)?$/)) {
packages.push(file)
}
});
for (let i = 0; i < packages.length; ++i) {
const pkg = packages[i]
const result = await execAndPrint(`cd ${pkg}; npm link --unsafe-perm; cd -`);
console.log(result.stderr)
}
for (let i = 0; i < packages.length; ++i) {
const pkg = packages[i]
let link = []
for (let j = 0; j < packages.length; ++j) {
const pkgRight = packages[j]
if (pkg === pkgRight) {
continue
}
link.push(pkgRight)
}
const result = await execAndPrint(`cd ${pkg}; npm link ${link.join(' ')} --unsafe-perm; cd -`);
console.log(result.stderr)
}
})