bin: remove .js support
This commit is contained in:
parent
94be72599b
commit
947a260285
18
bin/bootstrap.js
vendored
18
bin/bootstrap.js
vendored
@ -1,28 +1,16 @@
|
||||
const cluster = require('cluster');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
|
||||
/**
|
||||
* get raw config object from js or json
|
||||
* get raw config object from json
|
||||
* @param file
|
||||
* @returns {object}
|
||||
*/
|
||||
function obtainConfig(file) {
|
||||
let json;
|
||||
try {
|
||||
const ext = path.extname(file);
|
||||
// TODO: remove .js support in v2.6.x for security reason
|
||||
if (ext === '.js') {
|
||||
// require .js directly
|
||||
delete require.cache[require.resolve(file)];
|
||||
json = require(file);
|
||||
console.warn(chalk.yellow.underline('\n>> WARN: using .js configuration will be deprecated in v2.6.x, please use .json instead. <<\n'));
|
||||
} else {
|
||||
// others are treated as .json
|
||||
const jsonFile = fs.readFileSync(file);
|
||||
json = JSON.parse(jsonFile);
|
||||
}
|
||||
const jsonFile = fs.readFileSync(file);
|
||||
json = JSON.parse(jsonFile);
|
||||
} catch (err) {
|
||||
throw Error(`fail to load/parse your '${file}': ${err.message}`);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user