Skip to content

Commit 5096667

Browse files
committed
Support multiple extensions on --file-ext
1 parent 51ce10f commit 5096667

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cli.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ program.option('-c --config-file <file>', 'Use config file', function(configPath
189189
});
190190
program.option('--input-dir <dir>', 'Specify an input directory');
191191
program.option('--output-dir <dir>', 'Specify an output directory');
192-
program.option('--file-ext <text>', 'Specify an extension to be read, ex: html');
192+
program.option('--file-ext <text>', 'Specify extensions to be read, separated by commas, ex: html,htm,xml');
193193
var content;
194194
program.arguments('[files...]').action(function(files) {
195195
content = files.map(readFile).join('');
@@ -262,7 +262,7 @@ function processDirectory(inputDir, outputDir, fileExt) {
262262
else if (stat.isDirectory()) {
263263
processDirectory(inputFile, outputFile, fileExt);
264264
}
265-
else if (!fileExt || path.extname(file) === '.' + fileExt) {
265+
else if (!fileExt || ~fileExt.indexOf(path.extname(file).slice(1))) {
266266
mkdir(outputDir, function() {
267267
processFile(inputFile, outputFile);
268268
});
@@ -295,6 +295,9 @@ if (inputDir || outputDir) {
295295
else if (!outputDir) {
296296
fatal('You need to specify where to write the output files with the option --output-dir');
297297
}
298+
if (fileExt) {
299+
fileExt = fileExt.split(',');
300+
}
298301
processDirectory(inputDir, outputDir, fileExt);
299302
}
300303
// Minifying one or more files specified on the CMD line

0 commit comments

Comments
 (0)