Skip to content

Commit

Permalink
feat(lib): Run single file only when unnamed param is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermelimak committed Dec 10, 2017
1 parent 215c7c7 commit 607bdad
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ const prettier = require('prettier')

const pureUtils = require('./utils')

const { isVueSFC, readFile, writeToFile, splitChunks, isChanged } = pureUtils(fs)
const { isVueSFC, readFile, writeToFile, splitChunks, isChanged } = pureUtils(
fs
)

const { STYLE_START, STYLE_END, SCRIPT_START, SCRIPT_END } = pureUtils.constants

class PrettierVue {
Expand All @@ -16,6 +19,17 @@ class PrettierVue {
this.modified = {}
this.prettierOpts = {}

if (opts._ && opts._.length) {
const path = `${this.baseDir}/${opts._[0]}`

if (!isVueSFC(path)) {
return
}

this.format(path)
this.writeModified()
}

prettier.resolveConfig(this.configPath).then(options => {
this.prettierOpts = options
this.searchFiles()
Expand Down Expand Up @@ -70,7 +84,7 @@ class PrettierVue {
})

finder.on('end', () => {
this.writeModified(this.modified)
this.writeModified()
})
}

Expand Down

0 comments on commit 607bdad

Please sign in to comment.