mirror of
https://github.com/bdnugget/CodinGame-CLI.git
synced 2026-11-07 08:57:29 +00:00
config file available through --save (autoloads if existing in cwd)
This commit is contained in:
1 parent
51c0768141
commit
58b5578ecb
1 file changed
+15
@@ -2,6 +2,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { existsSync, readFileSync, writeFileSync } = require('fs');
|
||||
|
||||
const parseArgs = require('minimist');
|
||||
|
||||
const read = require('./testreader');
|
||||
@@ -15,6 +17,15 @@ const args = parseArgs(process.argv.slice(2), {
|
||||
}
|
||||
});
|
||||
|
||||
if (existsSync('codin.config.json')) {
|
||||
const config = JSON.parse(readFileSync('codin.config.json'));
|
||||
for (const [ key, value ] of Object.entries(config)) {
|
||||
if (!args[key] || Array.isArray(args[key]) && args[key].length === 0) {
|
||||
args[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const readTests = () => {
|
||||
if (args.test) {
|
||||
const testfiles = Array.isArray(args.test)
|
||||
@@ -52,6 +63,10 @@ const main = tests => {
|
||||
}
|
||||
};
|
||||
|
||||
if (args.save) {
|
||||
writeFileSync('codin.config.json', JSON.stringify(args, null, '\t'));
|
||||
}
|
||||
|
||||
if (args.size) {
|
||||
const files = Array.isArray(args.size)
|
||||
? args.size
|
||||
|
||||
Reference in new issue
Block a user