-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Allow color and label options for jest-diff #7980
Comments
Just a note that I'd also be interested in implementing feature if it sounds good to the maintainers |
Thanks for the proposal, this sounds like a reasonable feature addition to me. We should probably spend some time to design this in a flexible way though. |
Yes, the proposal makes sense. Two details come to my mind in this moment:
@jeysal Your thoughts on flexible design are welcome, since you also have independent use case. |
I like this idea! Make sure whatever design you come up with also handles word diffing, not just line diffing |
Regarding API design: |
@ewanharris With #8572 it looks like this issue has moved to the front burner. Here is a rough draft of options for you to critique: export type DiffOptions = {
aAnnotation?: string;
aChar?: string; // default '-'
aColor: Colorer; // default chalk.green
bAnnotation?: string;
bChar?: string; // default '+'
bColor: Colorer; // default chalk.red EDIT corrected the key
cChar?: string; // default ' '
cColor: Colorer; // default chalk.dim EDIT corrected the key
expand?: boolean;
contextLines?: number;
};
@SimenB The prototype pictures that we will soon make public confirm that @jeysal To keep from coupling too closely with |
- Before -1
+ After +1
- `${Ti.App.name} ${Ti.App.version} ${Ti.Platform.name} ${Ti.Platform.version}`
+ `${Ti.App.getName()} ${Ti.App.getVersion()} ${Ti.Platform.getName()} ${Ti.Platform.getVersion()}`
|
I think anything "character" or "char" might be dangerous in a Unicode context because it could be misunderstood as "byte", which is often the same thing as "char" |
What do you think about An example that comes to mind for third-party dependent is |
@pedrottimark, sorry for my radio silence here. I'll try and find some time in the next few days to respond |
Other than the comment from @jeysal that interface looks good to me. I could see some confusion over the usage of |
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Allowing passing custom colors/labels to jest-diff for use in the output.
Motivation
I'm using jest-diff in titanium-codemods, which is similar to react-codemod and uses jscodeshift to run transforms against code.
When a users asks for no files to be modified via the
--dry-run
flag, I output any differences by diffing the modified source, and the original source. The current jest-diff looks a little strange when I do this as the added code is always colored red with+
, or green with-
depending on which way round I choose. Both of these match the jest ecosystem with snapshots but don't fit for anyone attempting to use jest-diff in a different context.Example
I would imagine this would be implemented as parameter in the diffOptions type for jest-diff. Maybe like below, which fits in with the existing API
I'm unsure however as to whether I like the aColor/bColor argument. It seems odd to me to tie this specifically to something like chalk, but I guess the typedef is just an argument that takes a string and transforms the string as desired not a specific recommendation.
The text was updated successfully, but these errors were encountered: