Prettier: yarn run prettier throws an error, but directly invoking prettier works

Created on 1 Feb 2017  Â·  1Comment  Â·  Source: prettier/prettier

Encountered this issue on OS X Sierra, on bash/tmux.

This does not work:

10:17 $ yarn run prettier --write 'src/**/*.js'
yarn run v0.19.1
$ "/Users/deepak/code/personal/moocfetcher-appliance/client/node_modules/.bin/prettier"
Usage: prettier [opts] [filename ...]

Available options:
  --write                  Edit the file in-place. (Beware!)
  --stdin                  Read input from stdin.
  --print-width <int>      Specify the length of line that the printer will wrap on. Defaults to 80.
  --tab-width <int>        Specify the number of spaces per indentation-level. Defaults to 2.
  --single-quote           Use single quotes instead of double.
  --trailing-comma         Print trailing commas wherever possible.
  --bracket-spacing        Put spaces between brackets. Defaults to true.
  --parser <flow|babylon>  Specify which parse to use. Defaults to babylon.
  --color                  Colorize error messages. Defaults to true.
  --version                Print prettier version.

Boolean options can be turned off like this:
  --no-bracket-spacing
  --bracket-spacing=false
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

But this does:

$ ./node_modules/.bin/prettier --write 'src/**/*.js'
src/AppDispatcher.js
src/app.js
src/CopyCourses.js
src/CopyProgressPoller.js
src/CourseItem.js
src/CourseList.js
src/CourseStore.js
src/FilterLabel.js
src/Main.js
src/SearchBox.js
src/FilteredCourses.js
src/SelectedCourses.js
src/SelectionLabel.js
src/static/js/tether.min.js
src/static/js/jquery.min.js
src/static/js/bootstrap.min.js
locked-due-to-inactivity

Most helpful comment

You need to add in a --:

yarn run prettier -- --write 'src/**/*.js'

https://yarnpkg.com/docs/cli/run/#toc-yarn-run-script

>All comments

You need to add in a --:

yarn run prettier -- --write 'src/**/*.js'

https://yarnpkg.com/docs/cli/run/#toc-yarn-run-script

Was this page helpful?
0 / 5 - 0 ratings