-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.js
32 lines (25 loc) · 904 Bytes
/
update.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
const fs = require('fs');
const exec = require('child_process').exec;
const { execSync } = require('child_process');
const pluginConfig = fs.readFileSync('config.json');
const validDirectories = ['tools', 'demo-ng', 'demo-react', 'demo-svelte', 'demo-vue'];
function getDirectories(path) {
return fs.readdirSync(path).filter(function (file) {
return fs.statSync(path + '/' + file).isDirectory();
});
}
function updateRepo(name) {
const stdout = execSync(`cd ${name} && git status --porcelain`);
if (stdout.length !== 0) {
console.log(`${name} has uncommited files. Must be clean to update.`);
process.exit(1);
}
execSync(`cd ${name} && git checkout master && git pull`);
}
if (pluginConfig) {
for (const directory of getDirectories('.')) {
if (validDirectories.includes(directory)) {
updateRepo(directory);
}
}
}