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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work for absolute path #3

Open
kachkaev opened this issue Oct 31, 2018 · 2 comments
Open

Does not work for absolute path #3

kachkaev opened this issue Oct 31, 2018 · 2 comments

Comments

@kachkaev
Copy link

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: prettier/prettier#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!

@jurosh
Copy link
Owner

jurosh commented Jan 11, 2019

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...

@kachkaev
Copy link
Author

kachkaev commented Jan 11, 2019

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

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