Skip to content

Commit

Permalink
Support multiple extensions on --file-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
yumin-chen committed May 14, 2019
1 parent 51ce10f commit 5096667
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ program.option('-c --config-file <file>', 'Use config file', function(configPath
});
program.option('--input-dir <dir>', 'Specify an input directory');
program.option('--output-dir <dir>', 'Specify an output directory');
program.option('--file-ext <text>', 'Specify an extension to be read, ex: html');
program.option('--file-ext <text>', 'Specify extensions to be read, separated by commas, ex: html,htm,xml');
var content;
program.arguments('[files...]').action(function(files) {
content = files.map(readFile).join('');
Expand Down Expand Up @@ -262,7 +262,7 @@ function processDirectory(inputDir, outputDir, fileExt) {
else if (stat.isDirectory()) {
processDirectory(inputFile, outputFile, fileExt);
}
else if (!fileExt || path.extname(file) === '.' + fileExt) {
else if (!fileExt || ~fileExt.indexOf(path.extname(file).slice(1))) {
mkdir(outputDir, function() {
processFile(inputFile, outputFile);
});
Expand Down Expand Up @@ -295,6 +295,9 @@ if (inputDir || outputDir) {
else if (!outputDir) {
fatal('You need to specify where to write the output files with the option --output-dir');
}
if (fileExt) {
fileExt = fileExt.split(',');
}
processDirectory(inputDir, outputDir, fileExt);
}
// Minifying one or more files specified on the CMD line
Expand Down

0 comments on commit 5096667

Please sign in to comment.