Skip to content

Commit a68ac67

Browse files
authored
Revert "feat: support pkgInfo.egg.require (#45)" (#48)
This reverts commit fe179fd.
1 parent 48af4f7 commit a68ac67

File tree

6 files changed

+4
-73
lines changed

6 files changed

+4
-73
lines changed

.github/workflows/nodejs.yml

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ jobs:
3030
with:
3131
node-version: ${{ matrix.node-version }}
3232

33-
- name: update npm
34-
run: npm i -g npm
35-
3633
- name: Install Dependencies
3734
run: npm i -g npminstall && npminstall
3835

lib/command.js

+3-19
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ class Command extends BaseCommand {
2626
type: 'boolean',
2727
alias: [ 'ts', 'typescript' ],
2828
},
29-
30-
require: {
31-
description: 'inject to execArgv --require',
32-
type: 'array',
33-
alias: 'r',
34-
},
3529
};
3630

3731
this.logger = new Logger({
@@ -44,28 +38,18 @@ class Command extends BaseCommand {
4438
const context = super.context;
4539
const { argv, execArgvObj, cwd } = context;
4640

41+
// read `egg.typescript` from package.json
4742
let baseDir = argv._[0] || cwd;
4843
if (!path.isAbsolute(baseDir)) baseDir = path.join(cwd, baseDir);
4944
const pkgFile = path.join(baseDir, 'package.json');
5045
if (fs.existsSync(pkgFile)) {
5146
const pkgInfo = require(pkgFile);
52-
const eggInfo = pkgInfo.egg;
53-
54-
// read `egg.typescript` from package.json
55-
if (eggInfo && eggInfo.typescript) {
47+
if (pkgInfo && pkgInfo.egg && pkgInfo.egg.typescript) {
5648
argv.sourcemap = true;
5749
}
5850

59-
// read `egg.require` from package.json
60-
if (eggInfo && eggInfo.require && Array.isArray(eggInfo.require)) {
61-
execArgvObj.require = execArgvObj.require || [];
62-
eggInfo.require.forEach(injectScript => {
63-
execArgvObj.require.push(path.resolve(baseDir, injectScript));
64-
});
65-
}
66-
6751
// read argv from eggScriptsConfig in package.json
68-
if (pkgInfo.eggScriptsConfig && typeof pkgInfo.eggScriptsConfig === 'object') {
52+
if (pkgInfo && pkgInfo.eggScriptsConfig && typeof pkgInfo.eggScriptsConfig === 'object') {
6953
for (const key in pkgInfo.eggScriptsConfig) {
7054
if (argv[key] == null) argv[key] = pkgInfo.eggScriptsConfig[key];
7155
}

test/fixtures/pkg-config/config/config.default.js

-8
This file was deleted.

test/fixtures/pkg-config/inject.js

-3
This file was deleted.

test/fixtures/pkg-config/package.json

-9
This file was deleted.

test/start.test.js

+1-31
Original file line numberDiff line numberDiff line change
@@ -473,32 +473,6 @@ describe('test/start.test.js', () => {
473473
});
474474
});
475475

476-
describe('read pkgInfo', () => {
477-
let app;
478-
let fixturePath;
479-
480-
before(function* () {
481-
fixturePath = path.join(__dirname, 'fixtures/pkg-config');
482-
yield utils.cleanup(fixturePath);
483-
});
484-
485-
after(function* () {
486-
app.proc.kill('SIGTERM');
487-
yield utils.cleanup(fixturePath);
488-
});
489-
490-
it('should --require', function* () {
491-
app = coffee.fork(eggBin, [ 'start', '--workers=1', fixturePath ]);
492-
app.debug();
493-
app.expect('code', 0);
494-
495-
yield sleep(waitTime);
496-
497-
assert(app.stderr === '');
498-
assert(app.stdout.match(/@@@ inject by pkgInfo/));
499-
});
500-
});
501-
502476
describe('subDir as baseDir', () => {
503477
let app;
504478
const rootDir = path.join(__dirname, '..');
@@ -577,11 +551,7 @@ describe('test/start.test.js', () => {
577551
const exitEvent = awaitEvent(app.proc, 'exit');
578552
app.proc.kill('SIGTERM');
579553
const code = yield exitEvent;
580-
if (isWin) {
581-
assert(code === null);
582-
} else {
583-
assert(code === 0);
584-
}
554+
assert(code === 0);
585555
});
586556
});
587557
});

0 commit comments

Comments
 (0)