fix: find tsc in yarn workspace by ensuring no extra ANSI characters are present in 'yarn bin tsc' #906
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When running yarn (tested on ver.
1.22.19),yarn bin tscrun via Node.jsspawnoutputs extra leading ANSI characters, causing the path totscto look like the following:\x1B[2K\x1B[1G/Users/<username>/<path to project>/node_modules/.bin/tsc. This causes any call toexistsSyncto 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:Setting the env var
FORCE_COLORto0remediates the problem, which this PR brings.Test plan
Run
bob buildin a yarn project, ensure tsc is found successfully.Note
Runs
yarn bin tscwithFORCE_COLOR=0to avoid ANSI output and correctly detect thetscpath.packages/react-native-builder-bob/src/targets/typescript.ts):spawn('yarn', ['bin', 'tsc'])now setsenv: { ...process.env, FORCE_COLOR: '0' }to prevent ANSI characters in output and ensure accuratetscpath resolution.Written by Cursor Bugbot for commit 7c58e71. This will update automatically on new commits. Configure here.