Skip to content

Commit

Permalink
feat: switch to jsonc config
Browse files Browse the repository at this point in the history
  • Loading branch information
adamant-al committed Oct 30, 2022
1 parent b005ebe commit d1dc669
Show file tree
Hide file tree
Showing 4 changed files with 17,953 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
node_modules/
logs/
package-lock.json
tests.js
config.json.dev
config.test.jsonc
.idea
.editorconfig
.vscode
File renamed without changes.
14 changes: 11 additions & 3 deletions modules/configReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,19 @@ const fields = {
},
};
try {
if (isDev) {
config = JSON.parse(jsonminify(fs.readFileSync('./config.test', 'utf-8')));
let configFile;
if (isDev || process.env.JEST_WORKER_ID) {
configFile = './config.test.jsonc';
} else {
config = JSON.parse(jsonminify(fs.readFileSync('./config.json', 'utf-8')));
if (fs.existsSync('./config.jsonc')) {
configFile = './config.jsonc';
} else if (fs.existsSync('./config.json')) {
configFile = './config.json';
} else {
configFile = './config.default.json';
}
}
config = JSON.parse(jsonminify(fs.readFileSync(configFile, 'utf-8')));

let keysPair;
try {
Expand Down
Loading

0 comments on commit d1dc669

Please sign in to comment.