-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfollow.js
More file actions
30 lines (26 loc) · 833 Bytes
/
follow.js
File metadata and controls
30 lines (26 loc) · 833 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
const fs = require('fs-extra');
const child_process = require('child_process');
const exec = require('util').promisify(child_process.exec);
let followFile = process.argv[2] || 'followlist.txt';
async function follow(listFile) {
let content = await fs.readFile(listFile);
let lines = content.toString().split("\n");
for(let line of lines) {
let [name, url] = line.split(",");
if (!name || !url) continue;
download(name, url);
}
}
async function download(name, url) {
try {
let cmd = `node .\\cli.js -o ${name} ${url}`;
let args = ['.\\cli.js','-o',name,url]
console.log('execute', cmd);
child_process.spawnSync("node", args, {stdio: 'inherit'});
}catch(e) {
console.error(e);
}
}
follow(followFile).catch(e => {
console.error(e);
});