Skip to content

Commit

Permalink
feat(debug): [BREAKING_CHANGE] remove iron-node
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 16, 2017
1 parent 26427d9 commit c93fbc3
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
/node_modules/
coverage/
!test/fixtures/**/node_modules/aliyun-egg/
!test/fixtures/**/node_modules/
.tmp
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sudo: false
language: node_js
node_js:
- '4'
- '6'
- '7'
install:
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
environment:
matrix:
- nodejs_version: '4'
- nodejs_version: '6'
- nodejs_version: '7'

Expand Down
41 changes: 5 additions & 36 deletions lib/debug_command.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict';

const path = require('path');
const debug = require('debug')('egg-bin:debug');
const childprocess = require('childprocess');
const semver = require('semver');
const Command = require('./command');

class DebugCommand extends Command {
Expand All @@ -26,40 +23,12 @@ class DebugCommand extends Command {

yield this.helper.checkDeps();

// https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V6.md#2016-07-06-version-630-current-fishrock123
const hasInspector = semver.satisfies(process.versions.node, '>=6.3.0');
debug('%s %s, hasInspector:%s, NODE_ENV:%s, cwd:%s',
this.helper.serverBin, args.join(' '), hasInspector, options.env.NODE_ENV, process.cwd());
debug('%s %s, NODE_ENV:%s, cwd:%s',
this.helper.serverBin, args.join(' '), options.env.NODE_ENV, process.cwd());

if (hasInspector) {
options.execArgv = [
'--inspect',
];
} else {
// try to use iron-node@3 instead
// auto download iron-node at the first time
yield this.helper.getIronNodeBin(this.npmCli, cwd);

childprocess.inject(function(modulePath, args, opt) {
// this function will be toString() and save to tmp file
const cluster = require('cluster');
const originSetupMaster = cluster.setupMaster;
/* istanbul ignore next */
cluster.setupMaster = function(settings) {
if (!settings) return;
const args = settings.args || [];
args.unshift(settings.exec);
settings.args = args;
settings.exec = process.env.IRON_NODE_PATH;
originSetupMaster.call(cluster, settings);
};
return [ modulePath, args, opt ];
});

// iron-node should be installed in cwd,
// resolve after iron-node installed
options.env.IRON_NODE_PATH = require.resolve(path.join(process.cwd(), 'node_modules/iron-node/bin/run.js'));
}
options.execArgv = [
'--inspect',
];

this.helper.forkNode(this.helper.serverBin, args, options);
}
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@
"mocha": "bin/mocha.js"
},
"dependencies": {
"childprocess": "^2.0.2",
"commander": "^2.9.0",
"common-bin": "^1.0.0",
"debug": "^2.5.2",
"debug": "^2.6.0",
"detect-port": "^1.0.7",
"egg-utils": "^1.0.0",
"egg-utils": "^1.1.0",
"glob": "^7.1.1",
"intelli-espower-loader": "^1.0.1",
"istanbul": "^0.4.5",
"mkdirp": "^0.5.1",
"mocha": "^3.2.0",
"power-assert": "^1.4.2",
"rimraf": "^2.5.4",
"semver": "^5.3.0",
"thunk-mocha": "^1.0.8"
},
"devDependencies": {
Expand All @@ -33,7 +31,7 @@
"cross-env": "^3.1.3",
"egg-ci": "^1.1.0",
"enzyme": "^2.0.0",
"eslint": "^3.12.2",
"eslint": "^3.13.1",
"eslint-config-egg": "^3.2.0",
"jsdom": "^8.0.1",
"mm": "^2.0.0",
Expand All @@ -55,14 +53,14 @@
"autod": "autod"
},
"engines": {
"node": ">= 4.0.0"
"node": ">= 6.3.0"
},
"files": [
"bin",
"lib",
"index.js"
],
"ci": {
"version": "4, 6, 7"
"version": "6, 7"
}
}
10 changes: 10 additions & 0 deletions test/egg-dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ describe('egg-bin dev', () => {
.end(done);
});

it('should startCluster with custom yadan framework', done => {
const baseDir = path.join(__dirname, 'fixtures/custom-framework-app');
const customEgg = path.join(baseDir, 'node_modules', 'yadan');
coffee.fork(eggBin, [ 'dev' ], { cwd: baseDir })
// .debug()
.expect('stdout', `yadan start: {"baseDir":"${baseDir}","workers":1,"customEgg":"${customEgg}"}\n`)
.expect('code', 0)
.end(done);
});

describe('auto detect available port', () => {
let server;
before(done => {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions test/fixtures/custom-framework-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "custom-framework-app",
"egg": {
"framework": "yadan"
}
}

0 comments on commit c93fbc3

Please sign in to comment.