Return an error code when promise main() functions fail (#1002)

This commit is contained in:
toasted-nutbread 2020-11-07 11:34:14 -05:00 committed by GitHub
parent 0b003ef2c3
commit 7fa4782954
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 38 additions and 17 deletions

View File

@ -137,6 +137,16 @@ function createDictionaryArchive(dictionaryDirectory, dictionaryName) {
}
async function testMain(func) {
try {
await func();
} catch (e) {
console.log(e);
process.exit(-1);
}
}
module.exports = {
get JSZip() { return getJSZip(); },
getArgs,
@ -144,5 +154,6 @@ module.exports = {
getDefaultManifest,
getDefaultManifestAndVariants,
createManifestString,
createDictionaryArchive
createDictionaryArchive,
testMain
};

View File

@ -16,6 +16,7 @@
*/
const assert = require('assert');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM({console});
@ -218,4 +219,4 @@ function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -17,6 +17,7 @@
const assert = require('assert');
const crypto = require('crypto');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM({
@ -166,4 +167,4 @@ function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -19,7 +19,7 @@ const fs = require('fs');
const url = require('url');
const path = require('path');
const assert = require('assert');
const {JSZip, createDictionaryArchive} = require('../dev/util');
const {JSZip, createDictionaryArchive, testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
require('fake-indexeddb/auto');
@ -958,4 +958,4 @@ async function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -16,7 +16,7 @@
*/
const path = require('path');
const {createDictionaryArchive} = require('../dev/util');
const {createDictionaryArchive, testMain} = require('../dev/util');
const dictionaryValidate = require('../dev/dictionary-validate');
@ -62,4 +62,4 @@ async function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -19,6 +19,7 @@ const fs = require('fs');
const path = require('path');
const assert = require('assert');
const {JSDOM} = require('jsdom');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
@ -238,4 +239,4 @@ async function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -19,6 +19,7 @@ const fs = require('fs');
const path = require('path');
const assert = require('assert');
const {JSDOM} = require('jsdom');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
@ -180,4 +181,4 @@ async function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -16,6 +16,7 @@
*/
const assert = require('assert');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM();
@ -496,4 +497,4 @@ function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -18,7 +18,7 @@
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const {getDefaultManifest, createManifestString} = require('../dev/util');
const {getDefaultManifest, createManifestString, testMain} = require('../dev/util');
function loadManifestString() {
@ -38,4 +38,4 @@ function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -16,6 +16,7 @@
*/
const assert = require('assert');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM({});
@ -411,4 +412,4 @@ function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -19,6 +19,7 @@ const fs = require('fs');
const url = require('url');
const path = require('path');
const assert = require('assert');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
@ -627,4 +628,4 @@ async function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -16,6 +16,7 @@
*/
const assert = require('assert');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
@ -839,4 +840,4 @@ function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -16,6 +16,7 @@
*/
const assert = require('assert');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM();
@ -613,4 +614,4 @@ function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }

View File

@ -16,6 +16,7 @@
*/
const assert = require('assert');
const {testMain} = require('../dev/util');
const {VM} = require('../dev/vm');
const vm = new VM();
@ -230,4 +231,4 @@ function main() {
}
if (require.main === module) { main(); }
if (require.main === module) { testMain(main); }