forked from Honry/webpnp-test-automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (36 loc) · 1.06 KB
/
index.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
"use strict";
const path = require('path');
const fs = require('fs');
const fsPromises = fs.promises;
const cron = require('node-cron');
const { execSync } = require('child_process');
async function runMultiConfigs() {
const configDir = path.join(process.cwd(), 'configs');
const originConfigPath = path.join(process.cwd(), "config.json");
if (!fs.existsSync(configDir)) {
execSync('node main.js', {stdio: 'inherit'});
} else {
const configPaths = await fsPromises.readdir(configDir);
console.log(configPaths);
if (configPaths.length === 0) {
execSync('node main.js', {stdio: 'inherit'});
} else {
for (let configPath of configPaths) {
await fsPromises.copyFile(path.join(configDir, configPath), originConfigPath);
execSync('node main.js', {stdio: 'inherit'});
}
}
}
}
var myArgs = process.argv.slice(2);
console.log(process.argv);
console.log('1234');
const useCron = false;
const sched = "0 0 0 * * Sat";
if (useCron) {
cron.schedule(sched, () => {
runMultiConfigs();
});
} else {
runMultiConfigs();
}