Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use context.env instead of process.env #58

Merged
merged 4 commits into from
Jun 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
node_modules/
coverage/
!test/fixtures/custom-framework-app/node_modules/
!test/fixtures/demo-app/node_modules/aliyun-egg
test/fixtures/demo-app/node_modules/aliyun-egg/node_modules/
!test/fixtures/demo-app/node_modules/aliyun-egg/node_modules/
!test/fixtures/test-files-glob/**
.tmp
.vscode
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: node_js
node_js:
- '6'
- '7'
- '8'
install:
- npm i npminstall && npminstall
script:
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ environment:
matrix:
- nodejs_version: '6'
- nodejs_version: '7'
- nodejs_version: '8'

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
2 changes: 1 addition & 1 deletion lib/cmd/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class DevCommand extends Command {
const devArgs = yield this.formatArgs(context);
const options = {
execArgv: context.execArgv,
env: Object.assign({ NODE_ENV: 'development' }, process.env),
env: Object.assign({ NODE_ENV: 'development' }, context.env),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

方便上层 bin 覆盖 env

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

内网版那里有可能也要跟着改

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要,内网是继承的

};
debug('%s %j %j, %j', this.serverBin, devArgs, options.execArgv, options.env.NODE_ENV);
yield this.helper.forkNode(this.serverBin, devArgs, options);
Expand Down
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"dependencies": {
"change-case": "^3.0.1",
"co-mocha": "^1.2.0",
"common-bin": "^2.3.0",
"debug": "^2.6.4",
"detect-port": "^1.1.1",
"egg-utils": "^2.1.0",
"common-bin": "^2.4.0",
"debug": "^2.6.8",
"detect-port": "^1.1.3",
"egg-utils": "^2.2.0",
"globby": "^6.1.0",
"intelli-espower-loader": "^1.0.1",
"istanbul": "^1.1.0-alpha.1",
"mocha": "^3.3.0",
"mocha": "^3.4.2",
"mz-modules": "^1.0.0",
"power-assert": "^1.4.2",
"ypkgfiles": "^1.4.0"
Expand All @@ -27,12 +27,12 @@
"babel": "^6.3.26",
"babel-preset-airbnb": "^1.0.1",
"babel-register": "^6.4.3",
"coffee": "^3.3.0",
"coffee": "^3.3.2",
"cross-env": "^3.1.3",
"egg-ci": "^1.6.0",
"egg-ci": "^1.7.0",
"enzyme": "^2.0.0",
"eslint": "^3.19.0",
"eslint-config-egg": "^3.2.0",
"eslint-config-egg": "^4.2.0",
"jsdom": "^8.0.1",
"mm": "^2.1.0",
"mz": "^2.6.0",
Expand All @@ -44,14 +44,18 @@
"type": "git",
"url": "https://github.com/eggjs/egg-bin.git"
},
"bug": {
"url": "https://github.com/eggjs/egg/issues"
},
"homepage": "https://github.com/eggjs/egg-bin",
"author": "fengmk2 <[email protected]> (https://fengmk2.com)",
"scripts": {
"lint": "eslint .",
"pkgfiles": "node ./bin/egg-bin.js pkgfiles --check",
"test": "npm run lint -- --fix && npm run test-local",
"test-local": "node ./bin/egg-bin.js test -t 3600000",
"cov": "node ./bin/egg-bin.js cov -t 3600000",
"ci": "npm run lint && npm run cov",
"ci": "npm run lint && npm run pkgfiles && npm run cov",
"autod": "autod"
},
"engines": {
Expand All @@ -63,6 +67,6 @@
"bin"
],
"ci": {
"version": "6, 7"
"version": "6, 7, 8"
}
}
1 change: 1 addition & 0 deletions test/fixtures/demo-app/node_modules/aliyun-egg/index.js

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

10 changes: 6 additions & 4 deletions test/lib/cmd/debug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ describe('test/lib/cmd/debug.test.js', () => {

afterEach(mm.restore);

it('should startCluster success', done => {
coffee.fork(eggBin, [ 'debug' ], { cwd })
it('should startCluster success', () => {
return coffee.fork(eggBin, [ 'debug' ], { cwd })
.debug()
.expect('stderr', /Debugger listening/)
.expect('stderr', /chrome-devtools:/)
// node 8 missing "chrome-devtools" url
// .expect('stderr', /chrome-devtools:/)
.expect('stdout', /"workers":1/)
.expect('code', 0)
.end(done);
.end();
});

it('should startCluster with port', done => {
Expand Down
23 changes: 20 additions & 3 deletions test/lib/cmd/dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@
const path = require('path');
const coffee = require('coffee');
const net = require('net');
const mm = require('mm');

describe('test/lib/cmd/dev.test.js', () => {
const eggBin = require.resolve('../../../bin/egg-bin.js');
const cwd = path.join(__dirname, '../../fixtures/demo-app');

it('should startCluster success', done => {
coffee.fork(eggBin, [ 'dev' ], { cwd })
afterEach(mm.restore);

it('should startCluster success', () => {
mm(process.env, 'NODE_ENV', 'development');
return coffee.fork(eggBin, [ 'dev' ], { cwd })
// .debug()
.expect('stdout', /"workers":1/)
.expect('stdout', /"baseDir":".*?demo-app"/)
.expect('stdout', /"framework":".*?aliyun-egg"/)
.expect('stdout', /NODE_ENV: development/)
.expect('code', 0)
.end(done);
.end();
});

it('should dev start with custom NODE_ENV', () => {
mm(process.env, 'NODE_ENV', 'prod');
return coffee.fork(eggBin, [ 'dev' ], { cwd })
// .debug()
.expect('stdout', /"workers":1/)
.expect('stdout', /"baseDir":".*?demo-app"/)
.expect('stdout', /"framework":".*?aliyun-egg"/)
.expect('stdout', /NODE_ENV: prod/)
.expect('code', 0)
.end();
});

it('should startCluster with --harmony success', done => {
Expand Down