-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.js
54 lines (43 loc) · 1.41 KB
/
build.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
50
51
52
53
54
import fs from 'fs/promises';
let [qunitJS, qunitCSS, _] = await Promise.all([
fs.readFile('./node_modules/qunit/qunit/qunit.js'),
fs.readFile('./node_modules/qunit/qunit/qunit.css'),
fs.mkdir('./vendor', { recursive: true })
]);
let newQUnit = qunitJS.toString().replace(
'start: function start(count) {',
`reset: function() {
ProcessingQueue.finished = false;
globalStartCalled = false;
runStarted = false;
config.queue.length = 0;
config.modules.length = 0;
config.autostart = false;
Object.assign(config.stats, { total: 0, passed: 0, failed: 0, skipped: 0, todo: 0 });
[
"started", "updateRate", "filter", "depth", "current",
"pageLoaded", "timeoutHandler", "timeout", "pollution"
].forEach( ( key ) => delete config[ key ] );
const suiteReport = config.currentModule.suiteReport;
suiteReport.childSuites.length = 0;
delete suiteReport._startTime;
delete suiteReport._endTime;
config.modules.push( config.currentModule );
},
start: function start(count) {`);
await Promise.all([
fs.writeFile('./vendor/qunit.js', newQUnit),
fs.writeFile('./vendor/qunit.css', qunitCSS),
createPackageJSONIfNotExists()
]);
async function createPackageJSONIfNotExists() {
try {
await fs.stat('./vendor/package.json');
return true;
} catch (error) {
await fs.writeFile('./vendor/package.json', JSON.stringify({
name: 'qunitx-vendor',
version: '0.0.1'
}));
}
}