forked from jgthms/css-reference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.js
More file actions
31 lines (27 loc) · 977 Bytes
/
Copy pathinstall.js
File metadata and controls
31 lines (27 loc) · 977 Bytes
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
/* eslint-disable eol-last */
const fs = require('fs/promises');
const { spawn } = require('child_process');
const path = require('path');
const root = process.cwd();
// eslint-disable-next-line func-style
function npmInstall(cwd) {
return new Promise(resolve => {
const childProcess = spawn('npm', ['install'], { cwd });
childProcess.on('exit', resolve);
});
}
// eslint-disable-next-line func-style
async function install() {
const base = path.resolve(root);
const ignoreFolders = ['node_modules'];
const deps = (await fs.readdir(base, { withFileTypes: true }))
.filter(dep => dep.isDirectory())
.filter(dep => !ignoreFolders.includes(dep.name))
.map(folder => path.resolve(base, folder.name))
.concat([base])
.map(dep => npmInstall(dep));
await Promise.all(deps);
// eslint-disable-next-line no-console
console.log('Done!');
}
install();