Skip to content

Commit

Permalink
feat: egg-bin debug should detect debugger type
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 committed Aug 29, 2017
1 parent 476ea11 commit d82ff83
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/cmd/debug.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
'use strict';

const semver = require('semver');
const Command = require('./dev');

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
inspect: {
description: 'V8 Inspector port',
default: '',
default: newDebugger ? '' : undefined,
},
'inspect-brk': {
description: 'whether break at start',
},
debug: {
description: 'legacy debugger',
default: newDebugger ? undefined : '',
},
};
process.env.EGG_DEBUG = 'true';
}
Expand Down
3 changes: 1 addition & 2 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const BaseCommand = require('common-bin');
const changeCase = require('change-case');
const parser = require('yargs-parser');
const debug = require('debug')('egg-bin');

class Command extends BaseCommand {
/**
Expand All @@ -24,7 +23,7 @@ class Command extends BaseCommand {

// extract from WebStorm env `$NODE_DEBUG_OPTION`
if (context.env.NODE_DEBUG_OPTION) {
debug('Use $NODE_DEBUG_OPTION: %s', context.env.NODE_DEBUG_OPTION);
console.log('Use $NODE_DEBUG_OPTION: %s', context.env.NODE_DEBUG_OPTION);
const argvFromEnv = parser(context.env.NODE_DEBUG_OPTION);
debugPort = findDebugPort(argvFromEnv);
Object.assign(execArgvObj, extractExecArgv(argvFromEnv));
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"mz-modules": "^2.0.0",
"nyc": "^11.1.0",
"power-assert": "^1.4.4",
"semver": "^5.4.1",
"test-exclude": "^4.1.1",
"yargs-parser": "^7.0.0",
"ypkgfiles": "^1.4.0"
Expand Down

0 comments on commit d82ff83

Please sign in to comment.