Skip to content
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

Crash if calling diff on a deleted file #950

Closed
cbornet opened this issue Jul 18, 2016 · 2 comments
Closed

Crash if calling diff on a deleted file #950

cbornet opened this issue Jul 18, 2016 · 2 comments

Comments

@cbornet
Copy link

cbornet commented Jul 18, 2016

After calling this.fs.delete(foo.txt)
The generator asks

conflict foo.txt
? Overwrite foo.txt? (Ynaxdh)

Then if you chose d to show the diff, the generator crashes with TypeError: Cannot read property 'length' of null

This is because newFileContents is null in binary-diff.js and a call to newFileContents.length is made.

Also note that the existing foo.txt is a text file so the text diff should have been used instead of the binary but istextorbinary.isBinarySync(undefined, newFileContents) returns true.

@cbornet cbornet changed the title Crash if :q! Crash if calling diff on a deleted file Jul 18, 2016
@cbornet
Copy link
Author

cbornet commented Jul 18, 2016

Even if testing isBinarySync correctly for null content, the generator will then crash calling this.adapter.diff(existing.toString(), file.contents.toString());. So the best solution would probably to replace null file.contents by ''. I'm not sure where this should be done...

@SBoudrias
Copy link
Member

this.adapter.diff(existing.toString(), (file.contents || '').toString()); ?

dbushong added a commit to dbushong/generator that referenced this issue Jul 3, 2017
Makes `null` content (file deletion):

1. not identify as binary (so default diff style is nicer)
2. not break binary diff if it is

Addresses regression(?) of yeoman#950
dbushong added a commit to dbushong/generator that referenced this issue Jul 5, 2017
Makes `null` content (file deletion):

1. not identify as binary (so default diff style is nicer)
2. not break binary diff if it is

Addresses regression(?) of yeoman#950
SBoudrias pushed a commit that referenced this issue Jul 24, 2017
Makes `null` content (file deletion):

1. not identify as binary (so default diff style is nicer)
2. not break binary diff if it is

Addresses regression(?) of #950
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants