-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix locating
tsc
in yarn 3 workspaces (#462)
### Summary With Yarn 3, the aliases for binaries only seem to exist at the monorepo root `node_modules`, so the current logic fails to find `tsc`. This change uses `yarn bin tsc` to get the correct location for the `tsc` binary. ### Test plan Tested in the React Navigation monorepo
- Loading branch information
Showing
4 changed files
with
61 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import crossSpawn from 'cross-spawn'; | ||
|
||
export const spawn = async (...args: Parameters<typeof crossSpawn>) => { | ||
return new Promise<string>((resolve, reject) => { | ||
const child = crossSpawn(...args); | ||
|
||
let stdout = ''; | ||
let stderr = ''; | ||
|
||
child.stdout?.setEncoding('utf8'); | ||
child.stdout?.on('data', (data) => { | ||
stdout += data; | ||
}); | ||
|
||
child.stderr?.setEncoding('utf8'); | ||
child.stderr?.on('data', (data) => { | ||
stderr += data; | ||
}); | ||
|
||
child.once('error', reject); | ||
child.once('close', (code) => { | ||
if (code === 0) { | ||
resolve(stdout.trim()); | ||
} else { | ||
reject(new Error(stderr.trim())); | ||
} | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters