Closed noahehall closed 7 years ago
./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
hi @gucong3000
i do not have a separeted list of files, is it possible to send in a glob
./nodemodules/.bin/stylefmt -d -R ./src/*/_.css
LGM, I will push a PR to support glob
Awesome!
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"
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
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:
@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
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
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.
If a file after format has no difference with original, CLI will not Overlay file.
@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.
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
@rosendi Can you give me a test case?
@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.
@rosendi try postcss-cli
@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.
@morishitter Great! It works. Thank you!
P.S. The glob pattern should be {DIR1,DIR2}/**/*.css
anytime :)
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!
I just had the same problem and removed the quote mark '' around the path and it worked.
stylefmt --config .stylelintrc --recursive src/app/**/*.scss
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
;-)
./nodemodules/.bin/stylefmt -d -R ./src/*/_.css
gives error: cannot read property forEach of undefined