Browse files

In the event output is destined for a recognized file type that diffe…

…rs from the configured type, do the right thing. closes #2 (for real)
  • Loading branch information...
1 parent 21cb51b commit 3a1abe2fec498e8590588a6f2b74c30650c7b4b3 @evocateur committed Mar 18, 2013
Showing with 9 additions and 1 deletion.
  1. +9 −1 cli.js
View
10 cli.js
@@ -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]);
}

0 comments on commit 3a1abe2

Please sign in to comment.