From fcdccd7b3fc9bef87c0c4dace4ada4d8b30922a9 Mon Sep 17 00:00:00 2001 From: TZ Date: Fri, 3 Jul 2020 10:10:02 +0800 Subject: [PATCH] feat: expose proc --- lib/cmd/dev.js | 4 +++- package.json | 2 +- test/fixtures/my-egg-bin/lib/cmd/dev.js | 3 +++ test/my-egg-bin.test.js | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/cmd/dev.js b/lib/cmd/dev.js index 4d6248ff..d099ba86 100644 --- a/lib/cmd/dev.js +++ b/lib/cmd/dev.js @@ -69,7 +69,9 @@ class DevCommand extends Command { env: Object.assign(env, context.env), }; debug('%s %j %j, %j', this.serverBin, devArgs, options.execArgv, options.env.NODE_ENV); - yield this.helper.forkNode(this.serverBin, devArgs, options); + const task = this.helper.forkNode(this.serverBin, devArgs, options); + this.proc = task.proc; + yield task; } /** diff --git a/package.json b/package.json index 93affd61..cc74c6e9 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "autod": "^3.1.0", "chalk": "^2.4.2", "co-mocha": "^1.2.2", - "common-bin": "^2.8.1", + "common-bin": "^2.9.0", "debug": "^4.1.1", "detect-port": "^1.3.0", "egg-ts-helper": "^1.25.2", diff --git a/test/fixtures/my-egg-bin/lib/cmd/dev.js b/test/fixtures/my-egg-bin/lib/cmd/dev.js index 533b466b..9d92833e 100644 --- a/test/fixtures/my-egg-bin/lib/cmd/dev.js +++ b/test/fixtures/my-egg-bin/lib/cmd/dev.js @@ -8,6 +8,9 @@ class MyDevCommand extends DevCommand { // find your framework const yadan = path.join(__dirname, '../../../custom-framework-app/node_modules/yadan'); context.argv.framework = yadan; + setTimeout(() => { + console.log('proc: %s', this.proc.pid); + }, 1000); yield super.run(context); } } diff --git a/test/my-egg-bin.test.js b/test/my-egg-bin.test.js index 9879c86c..b0084c15 100644 --- a/test/my-egg-bin.test.js +++ b/test/my-egg-bin.test.js @@ -32,8 +32,9 @@ describe('test/my-egg-bin.test.js', () => { it('should my-egg-bin dev success', done => { coffee.fork(eggBin, [ 'dev' ], { cwd }) - // .debug() + .debug() .expect('stdout', /yadan start/) + .expect('stdout', /proc: \d+/) .expect('code', 0) .end(done); });