summaryrefslogtreecommitdiff
path: root/dev/build.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-09-19 19:04:28 -0400
committerGitHub <noreply@github.com>2020-09-19 19:04:28 -0400
commit51d4e5b0ff4c0054bf5012464414ec0657d09963 (patch)
tree9920d1a9c84bf968ca8105700450792d78ac0088 /dev/build.js
parent4293f731537906785da3b1f20535ddd18a4edd21 (diff)
Dev/test script organization (#846)
* Move lint scripts * Move dictionary-validate.js * Move schema-validate.js * Move createTestDictionaryArchive, remove yomichan-test.js * Rename yomichan-util.js to util.js * Move test/yomichan-vm.js to dev/vm.js * Move getArgs into util.js (and fix name) * Create test-all.js * Update test-code script
Diffstat (limited to 'dev/build.js')
-rw-r--r--dev/build.js50
1 files changed, 3 insertions, 47 deletions
diff --git a/dev/build.js b/dev/build.js
index 6afb82ae..b76a769b 100644
--- a/dev/build.js
+++ b/dev/build.js
@@ -19,8 +19,8 @@ const fs = require('fs');
const path = require('path');
const readline = require('readline');
const childProcess = require('child_process');
-const util = require('./yomichan-util');
-const {getAllFiles, getDefaultManifestAndVariants, createManifestString} = util;
+const util = require('./util');
+const {getAllFiles, getDefaultManifestAndVariants, createManifestString, getArgs} = util;
function clone(value) {
@@ -208,54 +208,10 @@ async function build(manifest, buildDir, extDir, manifestPath, variantMap, varia
}
}
-function getArs(args, argMap) {
- let key = null;
- let canKey = true;
- let onKey = false;
- for (const arg of args) {
- onKey = false;
-
- if (canKey && arg.startsWith('--')) {
- if (arg.length === 2) {
- canKey = false;
- key = null;
- onKey = false;
- } else {
- key = arg.substring(2);
- onKey = true;
- }
- }
-
- const target = argMap.get(key);
- if (typeof target === 'boolean') {
- argMap.set(key, true);
- key = null;
- } else if (typeof target === 'number') {
- argMap.set(key, target + 1);
- key = null;
- } else if (target === null || typeof target === 'string') {
- if (!onKey) {
- argMap.set(key, arg);
- key = null;
- }
- } else if (Array.isArray(target)) {
- if (!onKey) {
- target.push(arg);
- key = null;
- }
- } else {
- console.error(`Unknown argument: ${arg}`);
- key = null;
- }
- }
-
- return argMap;
-}
-
async function main() {
const argv = process.argv.slice(2);
- const args = getArs(argv, new Map([
+ const args = getArgs(argv, new Map([
['all', false],
['default', false],
['manifest', null],