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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stylefmt example broken for multiple files #164

Closed
richardgill opened this issue May 10, 2017 · 8 comments
Closed

stylefmt example broken for multiple files #164

richardgill opened this issue May 10, 2017 · 8 comments

Comments

@richardgill
Copy link

Here is a minimal example: https://github.com/richardgill/lint-staged-stylefmt-bug-example

stylefmt doesn't accept multiple files on the command line. Looks like there used to be a --list parameter, but it's not longer there.

Using --recursive works for me via npm run but doesn't work with lint-staged. I think I am seeing an additional -- getting added to the command which messes with stylefmt.

Note that is only an issue for when you break the css for multiple files (add spaces before the }'s to test. I think it works ok for one file.

Could you confirm that lint-staged is adding an extra -- and once I full understand what's going on. We can raise an issue with stylefmt.

Thanks,

@okonet
Copy link
Collaborator

okonet commented May 10, 2017

Yes, as of https://github.com/okonet/lint-staged/blob/master/src/findBin.js#L6

That's needed to be able to pass arguments to npm tasks. See https://docs.npmjs.com/cli/run-script

@okonet
Copy link
Collaborator

okonet commented May 10, 2017

Is this related to #138?

@richardgill
Copy link
Author

richardgill commented May 10, 2017

#138 would solve this usecase I think

stylefmt -r '${ paths }'would work (maybe without the 's)

It was also really difficult to figure out that -- was getting called I've commented here about that in #161

In the past I've manually added the --. I see it mentioned in the docs now I look for it, must have missed it!

I actually thing #138 would be how I'd do things by default, it means a new comer is more likely to understand what's going on.

Thanks for the library. It's saving my team and I loads of time!

@okonet
Copy link
Collaborator

okonet commented May 10, 2017

Yeah, good suggestion to make it default. I don't know if this will be too verbose though. If you have multiple commands it might become a pain to setup.

@chaucerbao
Copy link

I believe I've been running into this issue lately. Just wondering if there was a working solution around it until a fix is implemented.

It's been overwriting random files, possibly because the first argument for stylefmt is input-name and the second is output-name.

Usage: stylefmt [options] input-name [output-name]

@chaucerbao
Copy link

The workaround I'm using to account for -- with stylefmt is:

// package.json
...
  "lint-staged": {
    "*.scss": [
      "npm run stylefmt",
      "stylelint",
      "git add"
    ]
  },
  "scripts": {
    "stylefmt": "stylefmt --recursive"
  },
...

@okonet
Copy link
Collaborator

okonet commented Jun 21, 2017

@chaucerbao just FYI you might not need this workaround with the latest version since it removes the addition of -- for non-npm tasks. See #196

@chaucerbao
Copy link

@okonet Confirmed that it works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants