Sublime Forum

How to use csscomb from build system

#1

atm am using stylelint to lint & auto-fix the view, but i also wanted to use csscomb to sort the props so the build file looks like

{
    "shell_cmd": "/usr/local/bin/stylelint $file --fix;/usr/local/bin/csscomb $file;",
    "selector": "source.css, source.scss, source.sass, source.less"
}

now for some reason the csscomb doesnt work, while using the same cmnd in terminal works as expected, does anyone have this issue or know how to fix it ?

side note

is there a way to run multiple build systems on the same file one after another ?

0 Likes

#2

What do you mean exactly by “doesn’t work”?

I’m not sure offhand if shell_cmd supports the ; construct to chain commands, so as a first step, I would try to replace them with && instead. That will tell the shell to run csscomb but only if the stylelint command executed without failure, which at the very least is probably safer overall.

Note: You don’t need the trailing ; on the command since there’s nothing else to do after the second command finishes. Also it would be much more readable if you add /usr/local/bin to your PATH (if it’s not there already) so that you don’t have to specify it explicitly.

There’s no native way to execute multiple build systems in a row, although the API is present to create a plugin that would do such a thing. However note that build systems run in the background, so such a plugin would also have to wait for the current build to finish before starting the next one.

Most likely you’re better off doing what you’re doing above with multiple commands in one shell_cmd or, if you have more than a couple of commands, creating an external shell script that performs all of the steps and using that in your build system instead.

0 Likes

#3

many thanx for the help.

what i mean “that it doesnt work” is running that command from sublime, doesnt exec csscomb at all, even if it was the only cmnd in the build.

{
    "shell_cmd": "csscomb $file",
    "selector": "source.css, source.scss, source.sass, source.less"
}

and what is really strange is that when running the cmnd in terminal exactly the same as the build console

Running csscomb app.scss

without “Running” ofcourse , it works as expected, so am not sure what should i do to get it to work :disappointed:

Update

it seems csscomb needs to copy the buffer then replace it after, which with build system its not possible.

0 Likes