-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat: support ts from env and pkg #71
Conversation
lib/format_options.js
Outdated
@@ -39,6 +40,21 @@ module.exports = function formatOptions(options) { | |||
} | |||
options.customEgg = options.framework = framework; | |||
|
|||
// typescript | |||
if (!options.hasOwnProperty('typescript')) { | |||
if (process.env.EGG_TYPESCRIPT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
两个同时存在的时候,优先级是?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉 env 优先更合理一些
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那就是现在这种了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以命令行 > 环境 > pkg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该不存在命令行的情况, mm.app
都是手动调用的。
egg-bin 那边想影响这个,只能通过环境变量的方式默认配置
win 的那个测试还是没搞不明白 |
这个 win 是一直挂的? |
嗯,master 前几天也是这里挂的。单独 only 好像没事,一起跑就挂 |
Codecov Report
@@ Coverage Diff @@
## master #71 +/- ##
===========================================
- Coverage 94.89% 42.25% -52.65%
===========================================
Files 12 10 -2
Lines 588 568 -20
===========================================
- Hits 558 240 -318
- Misses 30 328 +298
Continue to review full report at Codecov.
|
c46a902
to
50ee2d2
Compare
lib/format_options.js
Outdated
@@ -39,6 +40,21 @@ module.exports = function formatOptions(options) { | |||
} | |||
options.customEgg = options.framework = framework; | |||
|
|||
// typescript | |||
if (!options.hasOwnProperty('typescript')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要 hasOwnProperty 吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options. typescript === undefined ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'typescript; in options
?
测试是不是就提供环境变量就好了
test/format_options.test.js
Outdated
const baseDir = path.join(__dirname, 'fixtures/demo'); | ||
mm(process, 'cwd', () => baseDir); | ||
mm(process.env, 'EGG_TYPESCRIPT', true); | ||
const opts = formatOptions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不是应该传 typescript 测一下优先级?
lib/format_options.js
Outdated
@@ -39,6 +40,21 @@ module.exports = function formatOptions(options) { | |||
} | |||
options.customEgg = options.framework = framework; | |||
|
|||
// typescript | |||
if (!options.hasOwnProperty('typescript')) { | |||
if (process.env.EGG_TYPESCRIPT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以命令行 > 环境 > pkg
lib/format_options.js
Outdated
const pkgFile = path.join(options.baseDir, 'package.json'); | ||
if (fs.existsSync(pkgFile)) { | ||
const pkgInfo = require(pkgFile); | ||
if (pkgInfo && pkgInfo.egg && pkgInfo.egg.typescript) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkgInfo.egg.typescript === true
// typescript | ||
if (!('typescript' in options)) { | ||
// process.env maybe force to string type | ||
if (String(process.env.EGG_TYPESCRIPT).toLowerCase() === 'true') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里 env 配置的时候,都会转换为 string 的,所以要这么处理
@popomore 可以再看看 |
可以合并了,覆盖率没更新 |
3.17.0 |
Checklist
npm test
passesAffected core subsystem(s)
Description of change