tsc-files
tsc-files copied to clipboard
tsc-files with yarn 3 pnp
When I run the command with yarn PNP (V.3.2.3) (which doesn't produce node_modules), I don't have any log and it pass despite the fact that I have an error in the file. As I can see when I run the command with npx, it create the temp config at the root of my project but doesn't resolve the library types but with yarn it doesn't even create the file. Any clues?
It won't resolve library types unless they're either imported or explicitly passed to the CLI. Strange that it isn't creating the config file. I suggest you to copy the source of tsc-files
(less than a hundred lines) to your own project so you can add some console logs and see what's going wrong.
@gustavopch
const { status } = spawnSync( "tsc", ['-p', tmpTsconfigPath, ...remainingArgsToForward], { stdio: 'inherit' }, )
(original is https://github.com/gustavopch/tsc-files/blob/master/lib/index.js#L44)
I managed to make it work with this code, since Yarn PNP has no node_modules folder, nor .bin folder, I think you must execute the command without a path so yarn can resolve it for you.
Maybe we could do a fallback for the path with a code like this ?
if (process.versions.pnp) { // do something with the PnP API ... } else { // fallback }
(https://yarnpkg.com/advanced/pnpapi#processversionspnp)
#!/bin/sh
if [ ! -f "$(dirname "$0")/_/husky.sh" ]; then
exit 0
fi
. "$(dirname "$0")/_/husky.sh"
yarn lint-staged
Btw here is my .husky/pre-commit file, you must use yarn there
Same problem with pnpm, IMHO you shouldn't try to resolve tsc yourself ever.
@DylanMerigaud Sorry for the super long delay. Implemented your suggestion in https://github.com/gustavopch/tsc-files/releases/tag/v1.1.4, so I'm closing this issue.
@wmertens When I call spawnSync('tsc')
, it doesn't find the binary because it's not installed globally.
@gustavopch normally when you run the command, you run it via npm scripts so they will have the installed node_modules tsc in the path.
A script's job is not to find executables. It should accept whatever executable the user deems appropriate, as given by the PATH
.