From 3b6819ccdc1f2f6c81482f45097adfe544e6c874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TZ=20=7C=20=E5=A4=A9=E7=8C=AA?= Date: Thu, 4 Apr 2019 08:53:29 +0800 Subject: [PATCH] fix: should not timeout when debugging (#129) --- lib/cmd/debug.js | 2 +- lib/cmd/test.js | 7 +++++-- test/lib/cmd/debug.test.js | 11 +++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/cmd/debug.js b/lib/cmd/debug.js index 8d2bf59b..c1713c89 100644 --- a/lib/cmd/debug.js +++ b/lib/cmd/debug.js @@ -69,7 +69,7 @@ class DebugCommand extends Command { proxy.start({ debugPort }).then(() => { // don't log within VSCode and WebStorm // TODO: don't start proxy within vscode and webstorm at next major - if (!process.env.VSCODE_CLI && !process.env.NODE_DEBUG_OPTION) { + if (!process.env.VSCODE_CLI && !process.env.NODE_DEBUG_OPTION && !process.env.JB_DEBUG_FILE) { console.log(chalk.yellow(`Debug Proxy online, now you could attach to ${proxyPort} without worry about reload.`)); if (newDebugger) console.log(chalk.yellow(`DevTools → ${proxy.url}`)); } diff --git a/lib/cmd/test.js b/lib/cmd/test.js index 03a90b2a..c00489dc 100644 --- a/lib/cmd/test.js +++ b/lib/cmd/test.js @@ -74,7 +74,10 @@ class TestCommand extends Command { * @return {Array} [ '--require=xxx', 'xx.test.js' ] * @protected */ - * formatTestArgs({ argv, debug }) { + * formatTestArgs({ argv, debugOptions }) { + // whether is debug mode, if pass --inspect then `debugOptions` is valid + // others like WebStorm 2019 will pass NODE_OPTIONS, and egg-bin itself will be debug, so could detect `process.debugPort`. + const isDebugging = debugOptions || process.debugPort; const testArgv = Object.assign({}, argv); /* istanbul ignore next */ @@ -83,7 +86,7 @@ class TestCommand extends Command { // force exit testArgv.exit = true; - if (debug) { + if (isDebugging) { // --no-timeouts testArgv.timeouts = false; testArgv.timeout = undefined; diff --git a/test/lib/cmd/debug.test.js b/test/lib/cmd/debug.test.js index e87ccb7f..c27028c1 100644 --- a/test/lib/cmd/debug.test.js +++ b/test/lib/cmd/debug.test.js @@ -111,5 +111,16 @@ describe('test/lib/cmd/debug.test.js', () => { .expect('code', 0) .end(); }); + + it('should not print devtools at webstorm 2019', function* () { + mm(process.env, 'JB_DEBUG_FILE', __filename); + const app = coffee.fork(eggBin, [ 'debug' ], { cwd }); + // app.debug(); + yield app.expect('stderr', /Debugger listening/) + .notExpect('stdout', /Debug Proxy online, now you could attach to 9999/) + .notExpect('stdout', /DevTools → chrome-devtools:.*:9999/) + .expect('code', 0) + .end(); + }); }); });