Skip to content
Permalink
Browse files

fix: should not timeout when debugging (#129)

  • Loading branch information
atian25 committed Apr 4, 2019
1 parent fcae123 commit 3b6819ccdc1f2f6c81482f45097adfe544e6c874
Showing with 17 additions and 3 deletions.
  1. +1 −1 lib/cmd/debug.js
  2. +5 −2 lib/cmd/test.js
  3. +11 −0 test/lib/cmd/debug.test.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}`));
}
@@ -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;
@@ -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();
});
});
});

0 comments on commit 3b6819c

Please sign in to comment.
You can’t perform that action at this time.