diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index ba86876..05760f6 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -30,9 +30,6 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: update npm - run: npm i -g npm - - name: Install Dependencies run: npm i -g npminstall && npminstall diff --git a/lib/command.js b/lib/command.js index b5df59d..d57c7ff 100644 --- a/lib/command.js +++ b/lib/command.js @@ -26,12 +26,6 @@ class Command extends BaseCommand { type: 'boolean', alias: [ 'ts', 'typescript' ], }, - - require: { - description: 'inject to execArgv --require', - type: 'array', - alias: 'r', - }, }; this.logger = new Logger({ @@ -44,28 +38,18 @@ class Command extends BaseCommand { const context = super.context; const { argv, execArgvObj, cwd } = context; + // read `egg.typescript` from package.json let baseDir = argv._[0] || cwd; if (!path.isAbsolute(baseDir)) baseDir = path.join(cwd, baseDir); const pkgFile = path.join(baseDir, 'package.json'); if (fs.existsSync(pkgFile)) { const pkgInfo = require(pkgFile); - const eggInfo = pkgInfo.egg; - - // read `egg.typescript` from package.json - if (eggInfo && eggInfo.typescript) { + if (pkgInfo && pkgInfo.egg && pkgInfo.egg.typescript) { argv.sourcemap = true; } - // read `egg.require` from package.json - if (eggInfo && eggInfo.require && Array.isArray(eggInfo.require)) { - execArgvObj.require = execArgvObj.require || []; - eggInfo.require.forEach(injectScript => { - execArgvObj.require.push(path.resolve(baseDir, injectScript)); - }); - } - // read argv from eggScriptsConfig in package.json - if (pkgInfo.eggScriptsConfig && typeof pkgInfo.eggScriptsConfig === 'object') { + if (pkgInfo && pkgInfo.eggScriptsConfig && typeof pkgInfo.eggScriptsConfig === 'object') { for (const key in pkgInfo.eggScriptsConfig) { if (argv[key] == null) argv[key] = pkgInfo.eggScriptsConfig[key]; } diff --git a/test/fixtures/pkg-config/config/config.default.js b/test/fixtures/pkg-config/config/config.default.js deleted file mode 100644 index 98de4f0..0000000 --- a/test/fixtures/pkg-config/config/config.default.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -exports.keys = '123456'; - -exports.logger = { - level: 'WARN', - consoleLevel: 'WARN', -}; diff --git a/test/fixtures/pkg-config/inject.js b/test/fixtures/pkg-config/inject.js deleted file mode 100644 index fd04a2f..0000000 --- a/test/fixtures/pkg-config/inject.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -console.log('@@@ inject by pkgInfo'); diff --git a/test/fixtures/pkg-config/package.json b/test/fixtures/pkg-config/package.json deleted file mode 100644 index 0999626..0000000 --- a/test/fixtures/pkg-config/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "example", - "version": "1.0.0", - "egg": { - "require": [ - "./inject.js" - ] - } -} diff --git a/test/start.test.js b/test/start.test.js index 7333c4d..a9ed9a4 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -473,32 +473,6 @@ describe('test/start.test.js', () => { }); }); - describe('read pkgInfo', () => { - let app; - let fixturePath; - - before(function* () { - fixturePath = path.join(__dirname, 'fixtures/pkg-config'); - yield utils.cleanup(fixturePath); - }); - - after(function* () { - app.proc.kill('SIGTERM'); - yield utils.cleanup(fixturePath); - }); - - it('should --require', function* () { - app = coffee.fork(eggBin, [ 'start', '--workers=1', fixturePath ]); - app.debug(); - app.expect('code', 0); - - yield sleep(waitTime); - - assert(app.stderr === ''); - assert(app.stdout.match(/@@@ inject by pkgInfo/)); - }); - }); - describe('subDir as baseDir', () => { let app; const rootDir = path.join(__dirname, '..'); @@ -577,11 +551,7 @@ describe('test/start.test.js', () => { const exitEvent = awaitEvent(app.proc, 'exit'); app.proc.kill('SIGTERM'); const code = yield exitEvent; - if (isWin) { - assert(code === null); - } else { - assert(code === 0); - } + assert(code === 0); }); }); });