jscodeshift-typescript-example
jscodeshift-typescript-example copied to clipboard
docs: fix target file wildcard argument
Current readme is incorrect. I actually got this instead when I tried it.
Command
I'm using an alias for convenience purposes. Pretend yarn mod is equivalent to npx jscodeshift.
yarn mod -t ./examples/simple-rename.ts --extensions=ts --parser=ts 'sandbox/**/*.ts' --print --dry
Output
csantarin ~/javascript-apps/jscodeshift-tsx-example (master) $ yarn mod -t ./examples/simple-rename.ts --extensions=ts --parser=ts 'sandbox/**/*.ts' --print --dry
# Don't mind the "yarn mod". I'm using the local project's jscodeshift instance.
yarn run v1.22.17
$ jscodeshift -t ./examples/simple-rename.ts --extensions=ts --parser=ts 'sandbox/**/*.ts' --print --dry
Skipping path sandbox/**/*.ts which does not exist.
No files selected, nothing to do.
All done.
Results:
0 errors
0 unmodified
0 skipped
0 ok
Time elapsed: 0.002seconds
✨ Done in 0.40s.
Target file: sandbox/bar/bar.ts
File structure:

Removing the single quotes allows the wildcard to work.
Thank for reporting @csantarin.
If I remember correctly I had the opposite issue.
Could you share info about your system? (OS, node, etc...) You can run this command to quickly get that info:
npx envinfo --system --binaries
Here is an example where using quotes result in "no files selected".

Folders:

System:
OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
@chimurai I see. I'm on macOS Big Sur and Zsh. You could be right. Blame it on OS & CLI differences, then?
System:
OS: macOS 11.6.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 742.74 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
Yarn: 1.22.17 - ~/.yarn/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
Watchman: 2022.01.24.00 - /usr/local/bin/watchman
I mean, in comparison, you're on Linux and Bash.
On MacOS and zsh I don't need quotes as well.
Curious which system you were using with those issues...
@chimurai so, when I use quotes in my wildcard, jscodeshift fails to read my files
yarn mod -t ./examples/simple-rename.ts --extensions=ts --parser=ts 'sandbox/**/*.ts' --print --dry
This detects my files successfully.
yarn mod -t ./examples/simple-rename.ts --extensions=ts --parser=ts sandbox/**/*.ts --print --dry
@chimurai so, when I use quotes in my wildcard,
jscodeshiftfails to read my filesyarn mod -t ./examples/simple-rename.ts --extensions=ts --parser=ts 'sandbox/**/*.ts' --print --dryThis detects my files successfully.
yarn mod -t ./examples/simple-rename.ts --extensions=ts --parser=ts sandbox/**/*.ts --print --dry
On which system did you experience this? (npx envinfo --system --binaries)