Closes #91. Add configuration option for custom Uncrustify path
This commit is contained in:
parent
0f51d0e124
commit
fefb25bf38
|
@ -4,6 +4,7 @@ Requires http://pear.php.net/package/PHP_Beautifier
|
|||
"use strict"
|
||||
fs = require("fs")
|
||||
temp = require("temp").track()
|
||||
possibleOptions = require "./possible-options.json"
|
||||
module.exports = (options, cb) ->
|
||||
text = ""
|
||||
|
||||
|
@ -35,12 +36,13 @@ module.exports = (options, cb) ->
|
|||
# jshint ignore: end
|
||||
# Remove misc
|
||||
delete options.languageOverride
|
||||
|
||||
delete options.configPath
|
||||
|
||||
|
||||
# Iterate over each property and write to configuration file
|
||||
for k of options
|
||||
# Remove all non-possible options
|
||||
isPossible = possibleOptions.indexOf(k) isnt -1
|
||||
if isPossible
|
||||
v = options[k]
|
||||
vs = v
|
||||
if typeof vs is "boolean"
|
||||
|
@ -49,6 +51,9 @@ module.exports = (options, cb) ->
|
|||
else
|
||||
vs = "False"
|
||||
text += k + " = " + vs + "\n"
|
||||
else
|
||||
# console.log("removing #{k} option")
|
||||
delete options[k]
|
||||
|
||||
# Create temp input file
|
||||
temp.open
|
||||
|
|
|
@ -1,45 +1,38 @@
|
|||
###
|
||||
Requires http://pear.php.net/package/PHP_Beautifier
|
||||
Requires http://uncrustify.sourceforge.net/
|
||||
###
|
||||
getCmd = (inputPath, outputPath, options, cb) ->
|
||||
|
||||
# console.log('Uncrustify options:', options);
|
||||
done = (configPath) ->
|
||||
|
||||
# console.log(configPath);
|
||||
if pathToCommand
|
||||
|
||||
# Use path given by user
|
||||
cmd = pathToCommand + " -c \"" + configPath + "\" -f \"" + inputPath + "\" -o \"" + outputPath + "\" -l \"" + lang + "\""
|
||||
else
|
||||
|
||||
# Use command available in $PATH
|
||||
cmd = "uncrustify -c \"" + configPath + "\" -f \"" + inputPath + "\" -o \"" + outputPath + "\" -l \"" + lang + "\""
|
||||
# console.log(cmd);
|
||||
cb cmd
|
||||
configPath = options.configPath
|
||||
lang = options.languageOverride or "C"
|
||||
pathToCommand = atom.config.get("atom-beautify.uncrustifyPath")
|
||||
# console.log(pathToCommand)
|
||||
unless configPath
|
||||
|
||||
# No custom config path
|
||||
cfg options, (error, path) ->
|
||||
throw error if error
|
||||
done path
|
||||
|
||||
else
|
||||
|
||||
# Has custom config path
|
||||
editor = atom.workspace.getActiveEditor()
|
||||
basePath = path.dirname(editor.getPath())
|
||||
|
||||
# console.log(basePath);
|
||||
configPath = path.resolve(basePath, configPath)
|
||||
done configPath
|
||||
return
|
||||
"use strict"
|
||||
cliBeautify = require("../cli-beautify")
|
||||
cfg = require("./cfg")
|
||||
path = require("path")
|
||||
getCmd = (inputPath, outputPath, options, cb) ->
|
||||
uncrustifyPath = options.uncrustifyPath
|
||||
# console.log('Uncrustify options:', options);
|
||||
# console.log("Uncrustify path: #{uncrustifyPath}")
|
||||
# Complete callback
|
||||
done = (configPath) ->
|
||||
# console.log(configPath);
|
||||
if uncrustifyPath
|
||||
# Use path given by user
|
||||
cmd = "#{uncrustifyPath} -c \"#{configPath}\" -f \"#{inputPath}\" -o \"#{outputPath}\" -l \"#{lang}\""
|
||||
else
|
||||
# Use command available in $PATH
|
||||
cmd = "uncrustify -c \"#{configPath}\" -f \"#{inputPath}\" -o \"#{outputPath}\" -l \"#{lang}\""
|
||||
# console.log(cmd);
|
||||
cb cmd
|
||||
configPath = options.configPath
|
||||
lang = options.languageOverride or "C" # Default is C
|
||||
unless configPath
|
||||
# No custom config path
|
||||
cfg options, (error, cPath) ->
|
||||
throw error if error
|
||||
done cPath
|
||||
else
|
||||
# Has custom config path
|
||||
editor = atom.workspace.getActiveEditor()
|
||||
basePath = path.dirname(editor.getPath())
|
||||
# console.log(basePath);
|
||||
configPath = path.resolve(basePath, configPath)
|
||||
done configPath
|
||||
return
|
||||
module.exports = cliBeautify(getCmd)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -100,33 +100,37 @@ module.exports =
|
|||
ruby_rbeautify_path: ""
|
||||
|
||||
# C
|
||||
c_uncrustifyPath: ""
|
||||
c_configPath: ""
|
||||
|
||||
# C++
|
||||
cpp_uncrustifyPath: ""
|
||||
cpp_configPath: ""
|
||||
|
||||
# Objective-C
|
||||
objectivec_uncrustifyPath: ""
|
||||
objectivec_configPath: ""
|
||||
|
||||
# C#
|
||||
cs_uncrustifyPath: ""
|
||||
cs_configPath: ""
|
||||
|
||||
# Objective-C
|
||||
# D
|
||||
d_uncrustifyPath: ""
|
||||
d_configPath: ""
|
||||
|
||||
# Java
|
||||
java_uncrustifyPath: ""
|
||||
java_configPath: ""
|
||||
|
||||
# Pawn
|
||||
pawn_uncrustifyPath: ""
|
||||
pawn_configPath: ""
|
||||
|
||||
# VALA
|
||||
vala_uncrustifyPath: ""
|
||||
vala_configPath: ""
|
||||
|
||||
# Uncrustify
|
||||
uncrustifyPath: ""
|
||||
|
||||
|
||||
# jshint ignore: end
|
||||
|
||||
# Process each language
|
||||
|
|
Loading…
Reference in New Issue