Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 3 additions & 19 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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];
}
Expand Down
8 changes: 0 additions & 8 deletions test/fixtures/pkg-config/config/config.default.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/fixtures/pkg-config/inject.js

This file was deleted.

9 changes: 0 additions & 9 deletions test/fixtures/pkg-config/package.json

This file was deleted.

32 changes: 1 addition & 31 deletions test/start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '..');
Expand Down Expand Up @@ -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);
});
});
});
Expand Down