Skip to content

Commit

Permalink
fix: should not timeout when debugging (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored Apr 4, 2019
1 parent fcae123 commit 3b6819c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/cmd/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`));
}
Expand Down
7 changes: 5 additions & 2 deletions lib/cmd/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions test/lib/cmd/debug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.