Skip to content

Commit

Permalink
fix: run build throw error will not exit (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 authored Oct 26, 2024
1 parent fa67e32 commit 1e675b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function run() {

// 添加 --listEmittedFiles 参数以便于获取编译后的文件列表
if (
tscArgs.includes('--watch') &&
!tscArgs.includes('--listEmittedFiles') &&
!tscArgs.includes('--version')
) {
Expand Down
7 changes: 7 additions & 0 deletions lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const forkTsc = (tscArgs = [], options = {}) => {
tscPath = localTscPath;
}

const isWatchMode = tscArgs.includes('--watch');

const child = spawn(tscPath, tscArgs, {
stdio: ['pipe', 'pipe', 'inherit'],
cwd: options.cwd,
Expand All @@ -48,6 +50,11 @@ const forkTsc = (tscArgs = [], options = {}) => {

child.stdout.on('data', data => {
data = data.toString('utf8');
if (!isWatchMode) {
console.log(data);
return;
}

const [text, fileChangedList] = filterFileChangedText(data);
if (fileChangedList.length) {
for (const file of fileChangedList) {
Expand Down

0 comments on commit 1e675b8

Please sign in to comment.