Use path and context to retrieve the directory

This commit is contained in:
Steven Zeck 2018-02-20 16:23:53 -06:00
parent b4c75b4837
commit 50172154c5
1 changed files with 3 additions and 2 deletions

View File

@ -2,6 +2,7 @@
Beautifier = require('./beautifier') Beautifier = require('./beautifier')
prettier = require("prettier") prettier = require("prettier")
path = require("path")
module.exports = class Prettier extends Beautifier module.exports = class Prettier extends Beautifier
name: "Prettier" name: "Prettier"
@ -23,7 +24,7 @@ module.exports = class Prettier extends Beautifier
Markdown: false Markdown: false
} }
beautify: (text, language, options) -> beautify: (text, language, options, context) ->
return new @Promise((resolve, reject) -> return new @Promise((resolve, reject) ->
_ = require('lodash') _ = require('lodash')
@ -33,7 +34,7 @@ module.exports = class Prettier extends Beautifier
else else
reject(new Error("Unknown language for Prettier")) reject(new Error("Unknown language for Prettier"))
filePath = atom.workspace.getActiveTextEditor().getPath() filePath = context.filePath and path.dirname context.filePath
try try
prettier.resolveConfig(filePath).then((configOptions) -> prettier.resolveConfig(filePath).then((configOptions) ->