I am creating a transform that will replace all instances of:
templateUrl: 'some/url/to/some.html'
with
template: require('some/url/to/some.html')
I am doing this because I am changing the way that our AngularJS code brings in their templates. I am going to make them all use the webpack string loader.
I have gotten the transform to work. But now I have no idea how to run it against all of the files in my project. I can't see in the documentation how to run this against all of the .js
files in my project. To run my transform, I currently type:
jscodeshift ./folder/myComponent.js -t ./tools/codemodes/template.js -d -p
This command will run my transform against the myComponent.js
file, but I want it to be run against all of the .js
files in my project. What do I need to change with my current command to make it select all .js
files, and run the transform against all of them?
If you want to run a transform against all files in a directory, you just enter the directory path, instead of a file path. In the example above, do the following:
jscodeshift ./folder -t ./tools/codemod/templates.js -d -p
That will run the transform against all of your nested js files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With