Lint-staged: csscomb doesn't work

Created on 11 Apr 2017  Â·  8Comments  Â·  Source: okonet/lint-staged

Hi,

I've tried to configure lint-staged to clean scss files with csscomb. Here is my conf:

"scripts": {
    "lint-staged": "lint-staged"
  },
  "pre-commit": "lint-staged",
  "lint-staged": {
    "*.scss": [
      "csscomb",
      "git add"
    ]
  }

If I run csscomb <file.scss> it works like a charm. But if I exec ./node_modules/.bin/lint-staged (or commit), the task run and never ends:

avr -11-2017 19-09-39

Most helpful comment

In order to get this to work for me instead of "csscomb --tty-mode", I used "csscomb --tty-mode --", (note the trailing -- in the command)

All 8 comments

I don't know how csscomb accepts arguments but it seems like an issue with it since I'm just passing arguments to commands as cmd -- <paths>. Might be the -- causing it? Can you investigate and submit a PR with the fix please?

csscomb -- src/test.scss works. I can investigate but I'm not sure I'll be able to find a fix…

Try verbose mode in the lint-staged config: https://github.com/okonet/lint-staged#options

It's weird. The command is correct, it works when I paste it, but when called from lint-staged, it seems to not find the command and keep waiting forever. I've just added a console.log here : https://github.com/csscomb/csscomb.js/blob/dev/src/cli.js#L2 The log appears when I exec the command manually but not when executing lint-staged.

I believe this is the issue: https://github.com/csscomb/csscomb.js/blob/dev/src/cli.js#L46

So it thinks it's not TTY (since it's being called by execa with child_process) and it is waiting for stdin. This is why it's waiting and not exiting.

This should be fixed in csscomb.

I'm closing it here since there is nothing I can do about it.

For future reference, the command works fine if you use it with the --tty-mode option.

Example:

  "lint-staged": {
    "src/**/*.{js,scss}": [
      "csscomb --tty-mode",
      "prettier --write",
      "git add"
    ]
  },

In order to get this to work for me instead of "csscomb --tty-mode", I used "csscomb --tty-mode --", (note the trailing -- in the command)

i used

"lint-staged": {
    "resources/assets/sass/**/*.sass": [
        "csscomb -t -c ./.csscomb.json",
        "git add"
    ]
},
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonslyvia picture jasonslyvia  Â·  3Comments

jitenderchand1 picture jitenderchand1  Â·  3Comments

OriginUnknown picture OriginUnknown  Â·  4Comments

okonet picture okonet  Â·  5Comments

timche picture timche  Â·  5Comments