jscodeshift-typescript-example icon indicating copy to clipboard operation
jscodeshift-typescript-example copied to clipboard

docs: fix target file wildcard argument

Open csantarin opened this issue 3 years ago • 6 comments
trafficstars

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: image

Removing the single quotes allows the wildcard to work.

csantarin avatar Jun 10 '22 08:06 csantarin

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

chimurai avatar Jun 15 '22 19:06 chimurai

Here is an example where using quotes result in "no files selected".

image

Folders: image

  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 avatar Jun 23 '22 18:06 chimurai

@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.

csantarin avatar Jun 24 '22 06:06 csantarin

On MacOS and zsh I don't need quotes as well.

Curious which system you were using with those issues...

chimurai avatar Jun 24 '22 10:06 chimurai

@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

csantarin avatar Jun 27 '22 09:06 csantarin

@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

On which system did you experience this? (npx envinfo --system --binaries)

chimurai avatar Jul 02 '22 20:07 chimurai