This repository has been archived on 2025-03-19. You can view files and clone it, but cannot push or open issues or pull requests.
TwitToMast/multi.js
Penelope Gomez / Pogmommy ed9d5c68fd 2.0.0
2023-02-14 14:35:57 -07:00

39 lines
1.2 KiB
JavaScript

//REQUIREMENTS
const childProcess = require('child_process')
const path = require('path');
const support = require('./ref/functions/support.js');
//FUNCTIONS
async function fork(scriptPath, args = []) {
return new Promise((resolve, reject) => {
let process = childProcess.fork(scriptPath, args, {
cwd: path.dirname(scriptPath)
});
process.on('exit', code => resolve(code));
process.on('error', err => reject(err));
});
}
//RUNTIME
(async function(){
const args = [...process.argv];
const defArgs = ["node","path","name","tweetCount","0","write","fromLoop"]
for (var i = 0; i < 2; i++) {args.shift();} //REMOVES `node ./TwitToMaster` from args
const config = require('fs').readFileSync("./usernameslist.txt").toString().split(/[\r\n]+/);//GET USERNAME LIST AS ARRAY
const customIndex = args.indexOf("-u");
console.log(args);
console.log(customIndex);
args.splice(customIndex,2);
console.log(args)
for (let name of config) {
var fArgs = [...args];
fArgs.push("-u");
fArgs.push(name);
console.log("args: " + fArgs);
await fork('./TwitToMast.js', fArgs);
}
}());