-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding --gitignore flag #508
Conversation
Adds a --gitignore flag that uses a .gitignore file in the current working directory to force jscodeshift to abstain from transforming files that match patterns specified in the .gitignore file. Please note that this feature is added primarily for the benefit of beginners to jscodeshift, as a way to make the enormously timesaving technique of passing a project's .gitignore file to jscodeshift easily discoverable and learnable. The idea is that when the user looks at the jscodeshift help page, "--gitignore" jumps right out at them and they immediately make the connection. It took me a year and a half of using jscodeshift before I realized I could simply just pass .gitignore to the utiliity, and creating a new ignore file for a freshly cloned project every day is an annoyance I wouldn't wish on others. Due to the --gitignore flag being a discoverability feature, renaming it to something generic would impede the discoverability it's trying to promote. Again, --gitignore is supposed to jump out at you from the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me. Thanks!
bin/__tests__/jscodeshift-test.js
Outdated
@@ -20,6 +20,7 @@ const path = require('path'); | |||
const temp = require('temp'); | |||
const mkdirp = require('mkdirp'); | |||
const testUtils = require('../../utils/testUtils'); | |||
const { chdir } = require('process'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove spaces - Facebook Meta style has no spaces around destructured variables
const {chdir} = require('process');
I guess we should configure Prettier for jscodeshift one day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Daniel15 fixed.
README.md
Outdated
jscodeshift -—ignore-config="MyIgnoreFile.gitignore" mytransform.js | ||
|
||
// More than one ignore file | ||
jscodeshift -—ignore-pattern="first_ignore_file.gitignore” -—ignore-pattern="second_ignore_file.gitignore” mytransform.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like all the new example commands use a hyphen and a dash (-—
) rather than two hyphens (--
). Can you please fix those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
jscodeshift -—ignore-pattern="first_ignored_dir/**/*” -—ignore-pattern="second_ignored_dir/**/*” mytransform.js | ||
``` | ||
|
||
__--ignore-config__ takes one or more paths to files containing lines with [.gitignore format](https://git-scm.com/docs/gitignore#_pattern_format) glob patterns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is --ignore-config
just like --gitignore
except you can specify the paths to the files with the ignore patterns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. --ignore-config
allows for more custom functionality than --gitignore
.
The problem was never that jscodeshift's ignore features didn't provide extensive custom functionality for advanced users; the problem was that jscodeshift's ignore functionality didn't provide any basic, easy-to-discover features for beginning users. --gitignore
is a simple UI affordance that directs new users to make use of their project's existing .gitignore file to ignore files that any sane person would never want to transform in a real world situation.
Adds a --gitignore flag that uses a .gitignore file in the current working directory to force jscodeshift to abstain from transforming files that match patterns specified in the .gitignore file.
Please note that this feature is added primarily for the benefit of beginners to jscodeshift, as a way to make the enormously timesaving technique of passing a project's .gitignore file to jscodeshift easily discoverable and learnable. The idea is that when the user looks at the jscodeshift help page, "--gitignore" jumps right out at them and they immediately make the connection.
It took me a year and a half of using jscodeshift before I realized I could simply just pass .gitignore to the utiliity, and creating a new ignore file for a freshly cloned project every day is an annoyance I wouldn't wish on others.
Due to the --gitignore flag being a discoverability feature, renaming it to something generic would impede the discoverability it's trying to promote.