fmt + output
This commit is contained in:
parent
59ddf6dda9
commit
8daaed1ef9
@ -77,27 +77,31 @@ const cqd_name_list = [
|
|||||||
'Iwn<Zo@nan',
|
'Iwn<Zo@nan',
|
||||||
'U>7D3Ol7uWKIfTC@XJ联队'
|
'U>7D3Ol7uWKIfTC@XJ联队'
|
||||||
]
|
]
|
||||||
|
|
||||||
function createJSDOMForOpponent(opponent, name, mode, testString, config, localStorageMock, path, results) {
|
function createJSDOMForOpponent(opponent, name, mode, testString, config, localStorageMock, path, results) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
new JSDOM(fs.readFileSync(path.join(__dirname, 'static/md5.html'), 'utf-8'), {
|
new JSDOM(fs.readFileSync(path.join(__dirname, 'static/md5.html'), 'utf-8'), {
|
||||||
url: 'file://' + path.join(__dirname, 'static/'),
|
url: 'file://' + path.join(__dirname, 'static/'),
|
||||||
runScripts: 'dangerously',
|
runScripts: 'dangerously',
|
||||||
resources: 'usable',
|
resources: 'usable',
|
||||||
beforeParse(window) {
|
beforeParse(window) {
|
||||||
window.FakelocalStorage = localStorageMock;
|
window.FakelocalStorage = localStorageMock;
|
||||||
window.config = config[mode].thresholds;
|
window.config = config[mode].thresholds;
|
||||||
window.name_input = testString[mode].replace(/\$name1/g, name).replace(/\$name2/g, opponent);
|
window.name_input = testString[mode].replace(/\$name1/g, name).replace(/\$name2/g, opponent);
|
||||||
window.stage = 0;
|
window.stage = 0;
|
||||||
window.skillData = [];
|
window.skillData = [];
|
||||||
window.resolve = (...args) => {
|
window.resolve = (...args) => {
|
||||||
results.push(args[2]);
|
results.push(args[2]);
|
||||||
window.close();
|
window.close();
|
||||||
resolve(); // 解决Promise,表示当前JSDOM操作完成
|
resolve(); // 解决Promise,表示当前JSDOM操作完成
|
||||||
}
|
};
|
||||||
}
|
window.output = (...message) => {
|
||||||
});
|
console.log('page:', message);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(chalk`{gray child {bold ${id}} started.}`);
|
console.log(chalk`{gray child {bold ${id}} started.}`);
|
||||||
process.on('message', ([mode, name]) => {
|
process.on('message', ([mode, name]) => {
|
||||||
|
|
||||||
@ -123,16 +127,16 @@ process.on('message', ([mode, name]) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}else if(mode == "CQD"){
|
} else if (mode == "CQD") {
|
||||||
var results=[];
|
var results = [];
|
||||||
(async () => {
|
(async () => {
|
||||||
for (let i = 0; i < cqd_name_list.length; i++) {
|
for (let i = 0; i < cqd_name_list.length; i++) {
|
||||||
var opponent = cqd_name_list[i];
|
var opponent = cqd_name_list[i];
|
||||||
// 等待当前的JSDOM操作完成
|
// 等待当前的JSDOM操作完成
|
||||||
await createJSDOMForOpponent(opponent, name, mode, testString, config, localStorageMock, path, results);
|
await createJSDOMForOpponent(opponent, name, mode, testString, config, localStorageMock, path, results);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
console.log(results)
|
console.log(results)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user