Skip to content

Commit

Permalink
fix: use context.env instead of process.env (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jun 3, 2017
1 parent d2f871c commit 9aa0030
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 20 deletions.
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),
};
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 <fengmk2@gmail.com> (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

0 comments on commit 9aa0030

Please sign in to comment.