nodejs-eol-converter-cli icon indicating copy to clipboard operation
nodejs-eol-converter-cli copied to clipboard

Does not work for absolute path

Open kachkaev opened this issue 7 years ago • 2 comments

Hi @jurosh 👋

I tried using eolConverter in lint-staged, but it did not work for me. Here's what my config looked like in package.json:

  "lint-staged": {
    "{**/*.md,{*,src/**/*}.{json,js,jsx,ts,tsx,css}}": [
      "prettier --write",
      "eolConverter",
      "git add"
    ]

Context: https://github.com/prettier/prettier/issues/5320

The above config resulted the following commands to run before committing:

prettier --write /path/to/repo/path/to/file1.js
prettier --write /path/to/repo/path/to/file2.js
eolConverter /path/to/repo/path/to/file1.js
eolConverter /path/to/repo/path/to/file2.js

eolConverter was treating /path/to/repo/path/to/file1.js as glob and converted it to /path/to/repo/path/to/repo/path/to/file1.js, which resulted into Error: ENOENT: no such file or directory.

It'd be great if your tool could deal with absolute paths too!

kachkaev avatar Oct 31 '18 12:10 kachkaev

Nice catch, what might solve it is adding more params - eg. eolConverter --absolutePath=true PATH which will deal with absolute path..

Hmm... or just check if first character is / and based on that make implicit use of absolute paths instead of glob...

jurosh avatar Jan 11 '19 21:01 jurosh

Thanks! BTW it feels like I managed to solve the problem by just adding * text=auto eol=lf to .gitattributes + configuring endOfLine: lf in Prettier

kachkaev avatar Jan 11 '19 21:01 kachkaev