Skip to content
Permalink
Browse files

fix: debug at 6.x

  • Loading branch information
atian25 authored and fengmk2 committed Sep 13, 2017
1 parent 678b83d commit 469739f1b494c647fcb06e0db432d435ed9e1805
Showing with 23 additions and 15 deletions.
  1. +3 −2 lib/cmd/debug.js
  2. +6 −3 package.json
  3. +14 −10 test/lib/cmd/debug.test.js
@@ -6,11 +6,11 @@ const InspectorProxy = require('inspector-proxy');
const debug = require('debug')('egg-bin');
const semver = require('semver');
const Command = require('./dev');
const newDebugger = semver.gte(process.version, '8.0.0');

class DebugCommand extends Command {
constructor(rawArgv) {
super(rawArgv);
const newDebugger = semver.gte(process.version, '8.0.0');
this.usage = 'Usage: egg-bin debug [dir] [options]';
this.options = {
// set default to empty so `--inspect` will always pass to fork
@@ -67,7 +67,8 @@ class DebugCommand extends Command {
const { debugPort, pid } = msg.data;
debug(`recieve new worker#${pid} debugPort: ${debugPort}`);
proxy.start({ debugPort }).then(() => {
console.log(chalk.yellow(`DevTools → ${proxy.url}`));
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}`));
});
}
});
@@ -9,17 +9,20 @@
},
"dependencies": {
"autod": "^2.9.0",
"chalk": "^2.1.0",
"co-mocha": "^1.2.0",
"common-bin": "^2.7.0",
"debug": "^3.0.1",
"detect-port": "^1.2.1",
"egg-utils": "^2.2.0",
"globby": "^6.1.0",
"inspector-proxy": "^1.0.0",
"intelli-espower-loader": "^1.0.1",
"mocha": "^3.5.0",
"mocha": "^3.5.3",
"mz-modules": "^2.0.0",
"nyc": "^11.2.0",
"nyc": "^11.2.1",
"power-assert": "^1.4.4",
"semver": "^5.4.1",
"test-exclude": "^4.1.1",
"ypkgfiles": "^1.4.0"
},
@@ -36,7 +39,7 @@
"eslint": "^4.6.1",
"eslint-config-egg": "^5.1.1",
"jsdom": "^8.0.1",
"mm": "^2.1.0",
"mm": "^2.2.0",
"mz": "^2.6.0",
"react": "^0.14.7",
"react-addons-test-utils": "^0.14.7",
@@ -4,6 +4,7 @@ const path = require('path');
const coffee = require('coffee');
const mm = require('egg-mock');
const net = require('net');
const semver = require('semver');

describe('test/lib/cmd/debug.test.js', () => {
const eggBin = require.resolve('../../../bin/egg-bin.js');
@@ -65,21 +66,24 @@ describe('test/lib/cmd/debug.test.js', () => {

describe('real egg', () => {
const cwd = path.join(__dirname, '../../fixtures/example');
const newDebugger = semver.gte(process.version, '8.0.0');

it('should proxy', () => {
return coffee.fork(eggBin, [ 'debug' ], { cwd })
// .debug()
.expect('stderr', /Debugger listening/)
.expect('stdout', /DevTools → chrome-devtools:.*:9999/)
it('should proxy', function* () {
const app = coffee.fork(eggBin, [ 'debug' ], { cwd });
// app.debug();
if (newDebugger) app.expect('stdout', /DevTools → chrome-devtools:.*:9999/);
yield app.expect('stderr', /Debugger listening/)
.expect('stdout', /Debug Proxy online, now you could attach to 9999/)
.expect('code', 0)
.end();
});

it('should proxy with port', () => {
return coffee.fork(eggBin, [ 'debug', '--proxy=6666' ], { cwd })
// .debug()
.expect('stderr', /Debugger listening/)
.expect('stdout', /DevTools → chrome-devtools:.*:6666/)
it('should proxy with port', function* () {
const app = coffee.fork(eggBin, [ 'debug', '--proxy=6666' ], { cwd });
// app.debug();
if (newDebugger) app.expect('stdout', /DevTools → chrome-devtools:.*:6666/);
yield app.expect('stderr', /Debugger listening/)
.expect('stdout', /Debug Proxy online, now you could attach to 6666/)
.expect('code', 0)
.end();
});

0 comments on commit 469739f

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