-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.js
49 lines (46 loc) · 1.25 KB
/
run.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
40
41
42
43
44
45
46
47
48
49
require('./helpers/my-js');
// const test= require('./singles/test-update-wl.js');
// console.log(test);
(async () => {
const args = process.argv.slice(2).map(val => {
if (val === 'true' || val === 'false') {
return Boolean(val === 'true');
} else if (!isNaN(val)) {
return Number(val);
} else if (val === '_') {
return undefined;
} else {
return val;
}
});
console.log({ args })
const toRun = args.shift();
// init
await require('./helpers/browser').init();
const folders = ['app-actions', 'cli', 'singles', 'scraping-actions'];
const getFile = file => {
for (let folder of folders) {
try {
const path = `./${folder}/${file}`;
console.log('checking', path)
const found = require(path);
console.log(`found at ${path}`);
return found;
} catch (e) {
console.log(e)
}
}
};
const fnToRun = getFile(toRun);
const response = await fnToRun(...args);
if (response) {
console.log('------------------');
console.log('| RESPONSE');
console.log('------------------');
console.log(JSON.stringify(response, null, 2));
}
console.log('done running');
// un-init
await require('./helpers/browser').close();
process.exit();
})();