Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 26, 2024
1 parent 996f96a commit e20d85a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
5 changes: 1 addition & 4 deletions src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ export default class Dev<T extends typeof Dev> extends BaseCommand<T> {
sticky: Flags.boolean({
description: 'start a sticky cluster server',
}),
env: Flags.string({
description: 'specify the NODE_ENV',
}),
};

public async run(): Promise<void> {
debug('NODE_ENV: %o', this.env);
this.env.NODE_ENV = this.flags.env ?? this.env.NODE_ENV ?? 'development';
this.env.NODE_ENV = this.env.NODE_ENV ?? 'development';
this.env.EGG_MASTER_CLOSE_TIMEOUT = '1000';
const serverBin = getSourceFilename('../scripts/start-cluster.mjs');
const eggStartOptions = await this.formatEggStartOptions();
Expand Down
17 changes: 3 additions & 14 deletions test/cmd/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('test/cmd/dev.test.ts', () => {
.end();
});

it.only('should dev start with custom NODE_ENV', () => {
it('should dev start with custom NODE_ENV', () => {
return coffee.fork(eggBin, [ 'dev' ], { cwd, env: { NODE_ENV: 'prod' } })
.debug()
.expect('stdout', /"workers":1/)
Expand All @@ -36,18 +36,7 @@ describe('test/cmd/dev.test.ts', () => {
.end();
});

it('should dev start with --env prod', () => {
return coffee.fork(eggBin, [ 'dev', '--env', 'prod' ], { cwd })
.debug()
.expect('stdout', /"workers":1/)
.expect('stdout', /"baseDir":".*?demo-app"/)
.expect('stdout', /"framework":".*?aliyun-egg"/)
.expect('stdout', /NODE_ENV: prod/)
.expect('code', 0)
.end();
});

it('should dev start work with declarations = true', () => {
it.skip('should dev start work with declarations = true', () => {
const cwd = getFixtures('example-declarations');
return coffee.fork(eggBin, [ 'dev' ], { cwd })
.debug()
Expand Down Expand Up @@ -183,7 +172,7 @@ describe('test/cmd/dev.test.ts', () => {
env: { EGG_BIN_DEFAULT_PORT: String(serverPort) },
})
// .debug()
.expect('stderr', /\[egg-bin] server port \d+ is in use, now using port \d+/)
.expect('stderr', /\[@eggjs\/bin] server port \d+ is unavailable, now using port \d+/)
.expect('code', 0)
.end(done);
});
Expand Down

0 comments on commit e20d85a

Please sign in to comment.