rtfpessoa / diff2html-cli

Pretty diff to html javascript cli (diff2html-cli)
https://diff2html.xyz
MIT License
514 stars 50 forks source link

Not able to run diff2html-cli on both windows and wsl #161

Open sahithnani opened 1 year ago

sahithnani commented 1 year ago

Hi Recently i've updated DIff2html-cli on my machine. This is the command i've used "diff2html -s side -F output.html -- file1.txt file2.txt" But all i'm getting is unknown arguments file1.txt, file2.txt. Can anyone help me with this. And also somehow its working on my friends machine. But he is using this flad "--renderNothingWhenEmpty". Here's the command he used "diff2html -s side --renderNothingWhenEmpty -F output.html -- file1.txt file2.txt". But for him the html report is getting generated even when there are no differences. image

I used a windows 10 machine and we have wsl installed with ubuntu 20.04. the machine is a dell precision5560.

rtfpessoa commented 12 months ago

What are you expecting that command to do?

ArthurAttout commented 11 months ago

@rtfpessoa for some reason I could never figure out, diff2html simply does not work under Powershell.

No matter what I try, it will always return the help menu, with only one reason

Unknown argument: diff.diff

For example the command diff2html -i file -- diff.diff work like a charm under git bash, but Powershell will simply not cooperate.

I suspect it has to do with arguments after -- not playing well with Powershell, but I never had the time to dive deeper in this.

rtfpessoa commented 11 months ago

I don't have a windows computer to test atm so I is a bit hard to validade without more information

ArthurAttout commented 11 months ago

Okay, I took a look at it, and it's because Powershell will drop double hyphens --, see this post

A double hyphen instructs PowerShell to treat everything coming after as literal arguments rather than options, so that you can pass for instance a literal -foo to your script/application/cmdlet.

diff2html will never see -- in argv so the last parameter is ambiguous.

Value of argv under git bash :

$ diff2html -i file -- patch.diff
[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\diff2html-cli\\bin\\d
iff2html.js',
  '-i',
  'file',
  '--',
  'patch.diff'
]

Value of argv under Powershell :

C:\Users\me\source\repos\test> diff2html -i file -- patch.diff
[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\diff2html-cli\\bin\\diff2html.js',
  '-i',
  'file',
  'patch.diff'
]

For the command to work under Powershell, the user needs to escape the double hyphens

diff2html -i file `-- diff.diff

or

diff2html -i file "--" diff.diff

It's ugly and there's basically nothing diff2html can do about it. But it could be worth an addition to the README, because most Powershell syntax never uses double hyphens, and users are little-aware about this.