Skip to content

Commit

Permalink
feat(cli): add the --stdin-filepath option
Browse files Browse the repository at this point in the history
This option is really usefull when using prettier-eslint-cli inside text
editor plugins, to let prettier-eslint discover the correct eslintrc
configuration for the given file.

Related:
* prettier#95
* sbdchd/neoformat#112
* prettier/prettier-emacs#10 (comment)
  • Loading branch information
BenoitZugmeyer committed Sep 27, 2017
1 parent b8bfe60 commit a9bc01b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/format-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function formatFilesFromArgv({
_: fileGlobs,
logLevel = logger.getLevel(),
stdin,
stdinFilepath,
write,
eslintPath,
prettierPath,
Expand All @@ -48,7 +49,7 @@ function formatFilesFromArgv({
}
const cliOptions = {write}
if (stdin) {
return formatStdin(prettierESLintOptions)
return formatStdin({filePath: stdinFilepath, ...prettierESLintOptions})
} else {
return formatFilesFromGlobs(
fileGlobs,
Expand Down
4 changes: 4 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const parser = yargs
type: 'boolean',
},
stdin: {default: false, describe: 'Read input via stdin', type: 'boolean'},
'stdin-filepath': {
describe: 'Path to the file to pretend that stdin comes from.',
coerce: coercePath,
},
'eslint-ignore': {
default: true,
type: 'boolean',
Expand Down

0 comments on commit a9bc01b

Please sign in to comment.