-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbulk-pull.js
More file actions
33 lines (28 loc) · 851 Bytes
/
bulk-pull.js
File metadata and controls
33 lines (28 loc) · 851 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
32
33
require("dotenv").config();
const { readdirSync } = require("fs");
const { exec } = require("child_process");
const currentDir = __dirname;
const dir = process.env.DIR;
const getDirectories = (source) =>
readdirSync(source, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
Promise.all(
getDirectories(dir).map((name) => {
return new Promise((resolve) => {
const command = `cd ${dir}/${name} && git pull`;
console.log(`Running \`${command}\``);
exec(command, (error, _, stderr) => {
if (stderr) {
console.log(`${name} failed: ${stderr}`);
}
if (error) {
console.log(`${name} failed: ${error}`);
}
resolve();
});
});
})
).then(() => {
exec(`cd ${currentDir}`, (error, _, stderr) => {});
});