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

how to specify multiple files in cli? #223

Closed
noahehall opened this issue Oct 18, 2016 · 21 comments
Closed

how to specify multiple files in cli? #223

noahehall opened this issue Oct 18, 2016 · 21 comments

Comments

@noahehall
Copy link

./node_modules/.bin/stylefmt -d -R ./src/*/.css

gives error: cannot read property forEach of undefined

@gucong3000
Copy link

./node_modules/.bin/stylefmt --help
Usage: stylefmt [options] input-name [output-name]

Options:

  -d, --diff             output diff against original file
  -l, --list             format list of space seperated files in place
  -R, --recursive        format files recursively
  -c, --config           path to a specific configuration file (JSON, YAML, or CommonJS)
  -b, --config-basedir   path to the directory that relative paths defining "extends"
  -v, --version          output the version number
  -h, --help             output usage information

-l, --list format list of space seperated files in place

@noahehall
Copy link
Author

noahehall commented Oct 18, 2016

hi @gucong3000

i do not have a separeted list of files, is it possible to send in a glob

./node_modules/.bin/stylefmt -d -R ./src/**/*.css

@gucong3000
Copy link

LGM, I will push a PR to support glob

@gucong3000 gucong3000 mentioned this issue Nov 15, 2016
3 tasks
@noahehall
Copy link
Author

Awesome!

@gucong3000
Copy link

Already support glob in #232

@noahehall , you can have a try.

npm i -g gucong3000/stylefmt#glob_support
stylefmt -d -l test/sass/**/*.css "!**/*.out.css"

@noahehall
Copy link
Author

just a note - if no .css files are found it throws error

Is it possible to silently fail if there aren't any css files ? or to show message vs throwing error.

I want to use this as part of my build process

@noahehall
Copy link
Author

noahehall commented Nov 19, 2016

the following does not work for me:

./node_modules/.bin/stylefmt -d -l src/**/*.css "!**/*.out.css"

it returns:
There is no difference with the original file.

fixable:
screen shot 2016-11-18 at 8 58 39 pm

@gucong3000
Copy link

@noahehall

just a note - if no .css files are found it throws error

Is it possible to silently fail if there aren't any css files ? or to show message vs throwing error.

I want to use this as part of my build process

It will show a message if no file matched: Files glob patterns specified did not match any css files.

https://github.com/morishitter/stylefmt/blob/master/bin/cli.js#L103

the following does not work for me:

Try ./node_modules/.bin/stylefmt -l src/**/*.scss, maybe a wrong file extension used.

One more thing, use master branch: npm i morishitter/stylefmt

@noahehall
Copy link
Author

noahehall commented Nov 21, 2016

still not working :(

./node_modules/.bin/stylefmt -l src/**/*.css

returns:
No files are formatted.

Here is the branch i am testing on: https://github.com/noahehall/udacity-trainschedule/tree/serviceworkers

@gucong3000
Copy link

I didn't find any problems in your branch.

E:\work\udacity-trainschedule (serviceworkers) (udacity-trainschedule@0.1.1)
λ .\node_modules\.bin\stylefmt -l src/**/*.css
No files are formatted.

E:\work\udacity-trainschedule (serviceworkers) (udacity-trainschedule@0.1.1)
λ .\node_modules\.bin\stylefmt -l src/**/*.css --diff
src/components/forms/calendar.css
There is no difference with the original file.

src/components/forms/inputmoment.css
There is no difference with the original file.

src/components/forms/slider.css
There is no difference with the original file.

src/components/forms/time.css
There is no difference with the original file.

src/components/forms/variables.css
There is no difference with the original file.

src/containers/main/main.css
There is no difference with the original file.

src/containers/notfound/notfound.css
There is no difference with the original file.

src/containers/page/page.css
There is no difference with the original file.

src/containers/start/daypicker.css
There is no difference with the original file.

src/containers/start/start.css
There is no difference with the original file.

src/theme/colors.css
There is no difference with the original file.

Then I changed one of your file (src/containers/start/start.css), and try again.

image

image

If a file after format has no difference with original, CLI will not Overlay file.

@danturu
Copy link

danturu commented Nov 22, 2016

@gucong3000 Is it possible to list with globs from npm scripts? The following script in a pure bash works fine: stylefmt --config .stylelintrc --list (src|packages)/**/*.css. But if I add it to the package's scripts it fails with the exit status 2 with a no error explanation.

Before v4 I did "lint:css:fix": "stylefmt --config .stylelintrc --list ls (src|packages)/**/*.css" and it worked fine. I definitely missed something obvious here.

@noahehall
Copy link
Author

Got it. Sounds like I need to update the style rules, interesting thing is, in atom I am getting formatting errors.

Ill review tonight and post updates

@gucong3000
Copy link

@rosendi Can you give me a test case?

@danturu
Copy link

danturu commented Nov 23, 2016

@gucong3000 Just put in your package.json:

scripts: {
  "lint:css:fix": "stylefmt --config .stylelintrc --list (DIR1|DIR2)/**/*.css"
}

...then run npm run lint:css:fix and it will fail.

@gucong3000
Copy link

@rosendi
try postcss-cli

@matype
Copy link
Owner

matype commented Nov 29, 2016

@rosendi please try

scripts: {
  "lint:css:fix": "stylefmt --config .stylelintrc --recursive '(DIR1|DIR2)/**/*.css'"
}

recursive pathes using glob have to use with quotes e.g. '' because its shell is expanded as a wild card.
and --list option is changed to --recursive (-r) when stylefmt v5 was released.

@danturu
Copy link

danturu commented Nov 29, 2016

@morishitter Great! It works. Thank you!

P.S. The glob pattern should be {DIR1,DIR2}/**/*.css

@matype
Copy link
Owner

matype commented Dec 1, 2016

anytime :)

@csmit175
Copy link

Hey i cant seem to get the glob format working. Im trying to run ./node_modules/.bin/stylefmt --recursive 'client/src/common/**/*.less' but just keep getting a message saying files glob patterns specified did not match any css files. Please help!

@sebelga
Copy link

sebelga commented Feb 10, 2017

I just had the same problem and removed the quote mark '' around the path and it worked.
stylefmt --config .stylelintrc --recursive src/app/**/*.scss

@sapegin
Copy link

sapegin commented Apr 27, 2017

Doesn’t work for me too but I have “TypeError: Cannot read property 'forEach' of undefined”

@sebelga When you omit quotes you’re using you shell expansion which may not work the same way on other platforms. Basically you just send a huge list of files to stylefmt ;-)

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

7 participants