Skip to content

Commit

Permalink
feat: optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
whxaxes committed Apr 25, 2021
1 parent d78314b commit 3f15e3e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,26 @@ class Command extends BaseCommand {
if (!path.isAbsolute(baseDir)) baseDir = path.join(cwd, baseDir);
const pkgFile = path.join(baseDir, 'package.json');
const pkgInfo = fs.existsSync(pkgFile) ? require(pkgFile) : null;
const eggInfo = pkgInfo && pkgInfo.egg;
const eggInfo = (pkgInfo && pkgInfo.egg) || {};
execArgvObj.require = execArgvObj.require || [];

// read `egg.typescript` from package.json if not pass argv
if (argv.typescript === undefined && eggInfo) {
argv.typescript = eggInfo.typescript === true;
if (argv.typescript === undefined && typeof eggInfo.typescript === 'boolean') {
argv.typescript = eggInfo.typescript;
}

// read `egg.declarations` from package.json if not pass argv
if (argv.declarations === undefined && eggInfo) {
argv.declarations = eggInfo.declarations === true;
if (argv.declarations === undefined && typeof eggInfo.declarations === 'boolean') {
argv.declarations = eggInfo.declarations;
}

// read `egg.tscompiler` from package.json if not pass argv
if (argv.tscompiler === undefined) {
argv.tscompiler = (eggInfo || {}).tscompiler || 'ts-node/register';
argv.tscompiler = eggInfo.tscompiler || 'ts-node/register';
}

// read `egg.require` from package.json
if (eggInfo && eggInfo.require && Array.isArray(eggInfo.require)) {
if (eggInfo.require && Array.isArray(eggInfo.require)) {
execArgvObj.require = execArgvObj.require.concat(eggInfo.require);
}

Expand Down

0 comments on commit 3f15e3e

Please sign in to comment.