Skip to content

Commit 7f5952f

Browse files
authored
fix: fix locating tsc in workspaces using yarn 1
### Summary When running yarn (tested on ver. `1.22.19`), `yarn bin tsc` run via Node.js `spawn` outputs extra leading ANSI characters, causing the path to `tsc` to look like the following: `\x1B[2K\x1B[1G/Users/<username>/<path to project>/node_modules/.bin/tsc`. This causes any call to `existsSync` to fail (the ANSI chars are non-printable so not visible below, but printing an object with the string as value shows them encoded), showing a false-positive warning: ``` ⚠ [typescript] Failed to locate tsc in the workspace. Falling back to the binary found in PATH at /Users/<username>/<path to project>/node_modules/.bin/tsc. Consider adding typescript to your devDependencies or specifying the tsc option for the typescript target. ``` Setting the env var `FORCE_COLOR` to `0` remediates the problem, which this PR brings. ### Test plan Run `bob build` in a yarn project, ensure tsc is found successfully.
1 parent eb0e43f commit 7f5952f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/react-native-builder-bob/src/targets/typescript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export default async function build({
112112
if (cli === 'yarn') {
113113
const result = await spawn('yarn', ['bin', 'tsc'], {
114114
cwd: root,
115+
env: { ...process.env, FORCE_COLOR: '0' },
115116
});
116117

117118
tsc = result.trim();

0 commit comments

Comments
 (0)