Skip to content

Commit

Permalink
ff
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 committed Mar 28, 2018
1 parent e701ea1 commit b20d05f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Command extends BaseCommand {
const baseDir = argv._[0] || argv.baseDir || cwd;
const pkgFile = path.join(baseDir, 'package.json');
if (fs.existsSync(pkgFile)) {
const pkgInfo = require(pkgFile);
const pkgInfo = JSON.parse(fs.readFileSync(pkgFile, 'utf-8'));
if (pkgInfo && pkgInfo.egg && pkgInfo.egg.typescript) {
argv.typescript = true;
}
Expand Down
57 changes: 31 additions & 26 deletions test/ts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,41 @@ describe('test/ts.test.js', () => {
.end();
});

it('should start app', () => {
if (process.env.EGG_VERSION && process.env.EGG_VERSION === '1') {
console.log('skip egg@1');
return;
}
cwd = path.join(__dirname, './fixtures/example-ts');
return coffee.fork(eggBin, [ 'dev', '--ts' ], { cwd })
// .debug()
.expect('stdout', /hi, egg, 12345/)
.expect('stdout', /started/)
.expect('code', 0)
.end();
});
describe('real application', () => {
before(() => {
cwd = path.join(__dirname, './fixtures/example-ts');
});
it('should start app', () => {
if (process.env.EGG_VERSION && process.env.EGG_VERSION === '1') {
console.log('skip egg@1');
return;
}
return coffee.fork(eggBin, [ 'dev', '--ts' ], { cwd })
// .debug()
.expect('stdout', /hi, egg, 12345/)
.expect('stdout', /started/)
.expect('code', 0)
.end();
});

it('should test app', () => {
if (process.env.EGG_VERSION && process.env.EGG_VERSION === '1') {
console.log('skip egg@1');
return;
}
cwd = path.join(__dirname, './fixtures/example-ts');
return coffee.fork(eggBin, [ 'test', '--ts' ], { cwd })
// .debug()
.expect('stdout', /hi, egg, 123456/)
.expect('stdout', /should work/)
.expect('code', 0)
.end();
it('should test app', () => {
if (process.env.EGG_VERSION && process.env.EGG_VERSION === '1') {
console.log('skip egg@1');
return;
}
return coffee.fork(eggBin, [ 'test', '--ts' ], { cwd })
// .debug()
.expect('stdout', /hi, egg, 123456/)
.expect('stdout', /should work/)
.expect('code', 0)
.end();
});
});

describe('egg.typescript = true', () => {
cwd = path.join(__dirname, './fixtures/example-ts-pkg');
before(() => {
cwd = path.join(__dirname, './fixtures/example-ts-pkg');
});

it('should start app', () => {
if (process.env.EGG_VERSION && process.env.EGG_VERSION === '1') {
Expand Down

0 comments on commit b20d05f

Please sign in to comment.