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: remove options.typescript support #73

Merged
merged 6 commits into from
Apr 21, 2018
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ Clean all logs directory, default is true.

If you are using `ava`, disable it.

#### typescript {Boolean}

Enable Typescript support, default is false.

Support read from `process.env.EGG_TYPESCRIPT`.

### app.httpRequest()

Request current app http server.
Expand Down
6 changes: 0 additions & 6 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,6 @@ mm.app({

如果是通过 ava 等并行测试框架进行测试,需要手动在执行测试前进行统一的日志清理,不能通过 mm 来处理,设置 `clean` 为 `false`。

#### typescript {Boolean}

开启 TypeScript 支持,默认关闭。

支持读取环境变量 `process.env.EGG_TYPESCRIPT`。

### app.httpRequest()

请求当前应用 http 服务的辅助工具。
Expand Down
5 changes: 0 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ export interface MockOption {
* Remove $baseDir/logs
*/
clean?: boolean;

/**
* Enable typescript support
*/
typescript?: boolean;
}

type EnvType = 'default' | 'test' | 'prod' | 'local' | 'unittest';
Expand Down
1 change: 0 additions & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class ClusterApplication extends Coffee {
* - {String} baseDir - The directory of the application
* - {Object} plugins - Tustom you plugins
* - {String} framework - The directory of the egg framework
* - {Boolean} [typescript] - Enable TypeScript support
* - {Boolean} [cache=true] - Cache application based on baseDir
* - {Boolean} [coverage=true] - Swtich on process coverage, but it'll be slower
* - {Boolean} [clean=true] - Remove $baseDir/logs
Expand Down
17 changes: 0 additions & 17 deletions lib/format_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const fs = require('fs');
const path = require('path');
const mm = require('mm');
const debug = require('debug')('mm');
Expand Down Expand Up @@ -40,22 +39,6 @@ module.exports = function formatOptions(options) {
}
options.customEgg = options.framework = framework;

// typescript
if (!('typescript' in options)) {
// process.env maybe force to string type
if (String(process.env.EGG_TYPESCRIPT).toLowerCase() === 'true') {
options.typescript = true;
} else {
const pkgFile = path.join(options.baseDir, 'package.json');
if (fs.existsSync(pkgFile)) {
const pkgInfo = require(pkgFile);
if (pkgInfo && pkgInfo.egg && pkgInfo.egg.typescript === true) {
options.typescript = true;
}
}
}
}

const plugins = options.plugins = options.plugins || {};

// add self as a plugin
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@
"mkdirp": "^0.5.1",
"mz-modules": "^1.0.0",
"pedding": "^1.1.0",
"sdk-base": "^3.0.1",
"ts-node": "^3.0.4",
"typescript": "^2.3.2"
"sdk-base": "^3.0.1"
},
"ci": {
"version": "6, 8, 9"
Expand Down
6 changes: 0 additions & 6 deletions test/fixtures/ts-false/package.json

This file was deleted.

6 changes: 0 additions & 6 deletions test/fixtures/ts/package.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/format_options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,41 +152,4 @@ describe('test/format_options.test.js', () => {
formatOptions();
assert.notEqual(process.env.HOME, baseDir);
});

describe('typescript', () => {
it('should read egg.typescript', () => {
const baseDir = path.join(__dirname, 'fixtures/ts');
mm(process, 'cwd', () => baseDir);
const opts = formatOptions();
assert(opts.typescript === true);
});

it('should read process.env.EGG_TYPESCRIPT', () => {
const baseDir = path.join(__dirname, 'fixtures/demo');
mm(process, 'cwd', () => baseDir);

mm(process.env, 'EGG_TYPESCRIPT', true);
assert(formatOptions().typescript === true);

mm(process.env, 'EGG_TYPESCRIPT', false);
assert(!formatOptions().typescript);

mm(process.env, 'EGG_TYPESCRIPT', 'true');
assert(formatOptions().typescript === true);

mm(process.env, 'EGG_TYPESCRIPT', 'false');
assert(!formatOptions().typescript);

mm(process.env, 'EGG_TYPESCRIPT', undefined);
assert(!formatOptions().typescript);
});

it('should read process.env.EGG_TYPESCRIPT with pkg', () => {
const baseDir = path.join(__dirname, 'fixtures/ts-false');
mm(process, 'cwd', () => baseDir);
mm(process.env, 'EGG_TYPESCRIPT', true);
const opts = formatOptions();
assert(opts.typescript === true);
});
});
});