diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 92acc76..e16d1a7 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -282,6 +282,7 @@ module.exports = class Beautifiers extends EventEmitter logger.verbose(allOptions) language ?= @getLanguage(grammar, filePath) + fileExtension = @getExtension(filePath) # Check if unsupported language if !language @@ -343,6 +344,7 @@ module.exports = class Beautifiers extends EventEmitter context = filePath: filePath + fileExtension: fileExtension startTime = new Date() beautifier.loadExecutables() @@ -405,7 +407,6 @@ module.exports = class Beautifiers extends EventEmitter if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors") return resolve( null ) else - fileExtension = @getExtension(filePath) repoBugsUrl = pkg.bugs.url title = "Atom Beautify could not find a supported beautifier for this file" detail = """ diff --git a/src/beautifiers/uncrustify/index.coffee b/src/beautifiers/uncrustify/index.coffee index ffaa46a..e2c878c 100644 --- a/src/beautifiers/uncrustify/index.coffee +++ b/src/beautifiers/uncrustify/index.coffee @@ -46,7 +46,9 @@ module.exports = class Uncrustify extends Beautifier Arduino: true } - beautify: (text, language, options) -> + beautify: (text, language, options, context) -> + fileExtension = context.fileExtension + uncrustify = @exe("uncrustify") # console.log('uncrustify.beautify', language, options) return new @Promise((resolve, reject) -> @@ -99,9 +101,9 @@ module.exports = class Uncrustify extends Beautifier "-c" configPath "-f" - @tempFile("input", text) + @tempFile("input", text, fileExtension and ".#{fileExtension}") "-o" - outputFile = @tempFile("output", text) + outputFile = @tempFile("output", text, fileExtension and ".#{fileExtension}") "-l" lang ])