Skip to content

Commit ac58d00

Browse files
zhennannpopomore
authored andcommitted
feat: cwd maybe not baseDir (#15)
1 parent 0c376a1 commit ac58d00

File tree

6 files changed

+52
-1
lines changed

6 files changed

+52
-1
lines changed

lib/cmd/start.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ class StartCommand extends Command {
122122
argv.daemon = undefined;
123123

124124
const options = {
125-
cwd: baseDir,
126125
execArgv: context.execArgv,
127126
env,
128127
stdio: 'inherit',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
module.exports = app => {
4+
app.get('/', function* () {
5+
this.body = `hi, ${app.config.framework || 'egg'}`;
6+
});
7+
8+
app.get('/env', function* () {
9+
this.body = app.config.env + ', ' + app.config.pre;
10+
});
11+
12+
app.get('/path', function* () {
13+
this.body = process.env.PATH;
14+
});
15+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
exports.keys = '123456';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "base-dir"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "subdir-as-basedir"
3+
}

test/start.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,34 @@ describe('test/start.test.js', () => {
335335
assert(result.data.toString() === 'hi, egg');
336336
});
337337
});
338+
339+
describe('subDir as baseDir', () => {
340+
let app;
341+
const rootDir = path.join(__dirname, '..');
342+
const subDir = path.join(__dirname, 'fixtures/subdir-as-basedir/base-dir');
343+
344+
before(function* () {
345+
yield utils.cleanup(rootDir);
346+
});
347+
348+
after(function* () {
349+
app.proc.kill('SIGTERM');
350+
yield utils.cleanup(rootDir);
351+
});
352+
353+
it('should start', function* () {
354+
app = coffee.fork(eggBin, [ 'start', '--workers=2', subDir ], { cwd: rootDir });
355+
// app.debug();
356+
app.expect('code', 0);
357+
358+
yield sleep(waitTime);
359+
360+
assert(app.stderr === '');
361+
assert(app.stdout.match(/egg started on http:\/\/127\.0\.0\.1:7001/));
362+
const result = yield httpclient.request('http://127.0.0.1:7001');
363+
assert(result.data.toString() === 'hi, egg');
364+
});
365+
});
338366
});
339367

340368
describe('start with daemon', () => {

0 commit comments

Comments
 (0)