In the event output is destined for a recognized file type that differs from the configured type, do the right thing. closes #2 (for real)

This commit is contained in:
Daniel Stockman 2013-03-18 14:00:43 -07:00
parent 21cb51b2b3
commit 3a1abe2fec

10
cli.js
View File

@ -205,7 +205,8 @@ function processInputSync(filepath) {
function makePretty(code, config, outfile, callback) {
try {
var pretty = beautify[config.type](code, config);
var fileType = getOutputType(outfile, config.type);
var pretty = beautify[fileType](code, config);
// ensure newline at end of beautified output
pretty += '\n';
@ -276,6 +277,13 @@ function dasherizeShorthands(hash) {
return hash;
}
function getOutputType(outfile, configType) {
if (outfile && /\.(js|css|html)$/.test(outfile)) {
return outfile.split('.').pop();
}
return configType;
}
function getScriptName() {
return path.basename(process.argv[1]);
}