Skip to content

Commit

Permalink
fix: 修复 Windows 环境下,tsc 编译的文件路径存在空格报错问题 (#65)
Browse files Browse the repository at this point in the history
* fix: 修复windows环境下,tsc编译的文件路径存在空格报错问题

* fix: 使用 JSON.stringify 序列化以转义 "

Co-authored-by: 章玉雪 <[email protected]>
Co-authored-by: Jay Fong <[email protected]>
  • Loading branch information
3 people authored Dec 8, 2021
1 parent b3ac811 commit 5ba8184
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,10 +542,12 @@ export class Generator {
// add this to fix bug that not-generator-file-on-window
const command = `${
require('os').platform() === 'win32' ? 'node ' : ''
}${require.resolve(`typescript/bin/tsc`)}`
}${JSON.stringify(require.resolve(`typescript/bin/tsc`))}`

exec(
`${command} --target ES2019 --module ESNext --jsx preserve --declaration --esModuleInterop ${file}`,
`${command} --target ES2019 --module ESNext --jsx preserve --declaration --esModuleInterop ${JSON.stringify(
file,
)}`,
{
cwd: this.options.cwd,
env: process.env,
Expand Down

0 comments on commit 5ba8184

Please sign in to comment.