Skip to content

Commit

Permalink
Allow multiple patterns specified
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerun committed Aug 27, 2019
1 parent 2b1ad75 commit c0895ff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -133,10 +133,9 @@ It also exposes one additional method that works similarly to its CLI:

- **cwd** - path where to execute prettier-standard
- **config** - object configuring execution
- **pattern** - pattern to use for formatting files (string)
- **patterns** - patterns to use for formatting files (array of strings)
- **check** - whether to check instead of format files (boolean, default: false)
- **onProcess** - callback that is called for each processed file matching pattern:
{ file, formatted, check, runtime }
- **onProcess** - callback that is called for each processed file matching pattern: { file, formatted, check, runtime }

## LICENSE

Expand Down
6 changes: 3 additions & 3 deletions src/cli.js
Expand Up @@ -40,8 +40,8 @@ async function main () {
}
})

if (flags._ && flags._.length > 0 && !flags.pattern) {
flags.pattern = flags._[0]
if (flags._ && flags._.length > 0) {
flags.patterns = flags._
}

const stdin = await getStdin()
Expand Down Expand Up @@ -81,7 +81,7 @@ async function main () {
}

const result = run(process.cwd(), {
pattern: flags.pattern,
patterns: flags.patterns,
check: flags.check || false,
options,
onProcessed: ({ file, formatted, check, runtime }) => {
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Expand Up @@ -23,13 +23,12 @@ function formatWithCursor (source, options) {
function run (cwd, config) {
const onProcessed = config.onProcessed || function () {}

const patterns = [
config.pattern,
const patterns = config.patterns.concat([
'!**/node_modules/**',
'!./node_modules/**',
'!**/.{git,svn,hg}/**',
'!./.{git,svn,hg}/**'
]
])

let filePaths
try {
Expand Down

0 comments on commit c0895ff

Please sign in to comment.