Closes #91. Add configuration option for custom Uncrustify path
This commit is contained in:
parent
0f51d0e124
commit
fefb25bf38
|
@ -120,7 +120,7 @@ getConfigOptionsFromSettings = (langs) ->
|
||||||
opt = k.replace(new RegExp("^" + lang + "_"), "")
|
opt = k.replace(new RegExp("^" + lang + "_"), "")
|
||||||
options[lang] = options[lang] or {}
|
options[lang] = options[lang] or {}
|
||||||
options[lang][opt] = config[k]
|
options[lang][opt] = config[k]
|
||||||
# console.log(lang, opt);
|
# console.log(lang, opt);
|
||||||
true
|
true
|
||||||
# console.log(options);
|
# console.log(options);
|
||||||
options
|
options
|
||||||
|
|
|
@ -4,6 +4,7 @@ Requires http://pear.php.net/package/PHP_Beautifier
|
||||||
"use strict"
|
"use strict"
|
||||||
fs = require("fs")
|
fs = require("fs")
|
||||||
temp = require("temp").track()
|
temp = require("temp").track()
|
||||||
|
possibleOptions = require "./possible-options.json"
|
||||||
module.exports = (options, cb) ->
|
module.exports = (options, cb) ->
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
|
@ -35,20 +36,24 @@ module.exports = (options, cb) ->
|
||||||
# jshint ignore: end
|
# jshint ignore: end
|
||||||
# Remove misc
|
# Remove misc
|
||||||
delete options.languageOverride
|
delete options.languageOverride
|
||||||
|
|
||||||
delete options.configPath
|
delete options.configPath
|
||||||
|
|
||||||
|
|
||||||
# Iterate over each property and write to configuration file
|
# Iterate over each property and write to configuration file
|
||||||
for k of options
|
for k of options
|
||||||
v = options[k]
|
# Remove all non-possible options
|
||||||
vs = v
|
isPossible = possibleOptions.indexOf(k) isnt -1
|
||||||
if typeof vs is "boolean"
|
if isPossible
|
||||||
if vs is true
|
v = options[k]
|
||||||
vs = "True"
|
vs = v
|
||||||
else
|
if typeof vs is "boolean"
|
||||||
vs = "False"
|
if vs is true
|
||||||
text += k + " = " + vs + "\n"
|
vs = "True"
|
||||||
|
else
|
||||||
|
vs = "False"
|
||||||
|
text += k + " = " + vs + "\n"
|
||||||
|
else
|
||||||
|
# console.log("removing #{k} option")
|
||||||
|
delete options[k]
|
||||||
|
|
||||||
# Create temp input file
|
# Create temp input file
|
||||||
temp.open
|
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"
|
"use strict"
|
||||||
cliBeautify = require("../cli-beautify")
|
cliBeautify = require("../cli-beautify")
|
||||||
cfg = require("./cfg")
|
cfg = require("./cfg")
|
||||||
path = require("path")
|
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)
|
module.exports = cliBeautify(getCmd)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -100,33 +100,37 @@ module.exports =
|
||||||
ruby_rbeautify_path: ""
|
ruby_rbeautify_path: ""
|
||||||
|
|
||||||
# C
|
# C
|
||||||
|
c_uncrustifyPath: ""
|
||||||
c_configPath: ""
|
c_configPath: ""
|
||||||
|
|
||||||
# C++
|
# C++
|
||||||
|
cpp_uncrustifyPath: ""
|
||||||
cpp_configPath: ""
|
cpp_configPath: ""
|
||||||
|
|
||||||
# Objective-C
|
# Objective-C
|
||||||
|
objectivec_uncrustifyPath: ""
|
||||||
objectivec_configPath: ""
|
objectivec_configPath: ""
|
||||||
|
|
||||||
# C#
|
# C#
|
||||||
|
cs_uncrustifyPath: ""
|
||||||
cs_configPath: ""
|
cs_configPath: ""
|
||||||
|
|
||||||
# Objective-C
|
# D
|
||||||
|
d_uncrustifyPath: ""
|
||||||
d_configPath: ""
|
d_configPath: ""
|
||||||
|
|
||||||
# Java
|
# Java
|
||||||
|
java_uncrustifyPath: ""
|
||||||
java_configPath: ""
|
java_configPath: ""
|
||||||
|
|
||||||
# Pawn
|
# Pawn
|
||||||
|
pawn_uncrustifyPath: ""
|
||||||
pawn_configPath: ""
|
pawn_configPath: ""
|
||||||
|
|
||||||
# VALA
|
# VALA
|
||||||
|
vala_uncrustifyPath: ""
|
||||||
vala_configPath: ""
|
vala_configPath: ""
|
||||||
|
|
||||||
# Uncrustify
|
|
||||||
uncrustifyPath: ""
|
|
||||||
|
|
||||||
|
|
||||||
# jshint ignore: end
|
# jshint ignore: end
|
||||||
|
|
||||||
# Process each language
|
# Process each language
|
||||||
|
|
Loading…
Reference in New Issue