From cc010e3287ebeadf9e9bd51ffae83e20bbc30b23 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Thu, 13 Feb 2014 19:14:03 -0800 Subject: [PATCH] Support transforming multiple files at once --- npm-jsx_whitespace_transform/run.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/npm-jsx_whitespace_transform/run.js b/npm-jsx_whitespace_transform/run.js index fffa25a740..b0dd78dc90 100755 --- a/npm-jsx_whitespace_transform/run.js +++ b/npm-jsx_whitespace_transform/run.js @@ -146,22 +146,24 @@ if (require.main === module) { ); } - var absPath = path.resolve(argv._[0]); + argv._.forEach(function(arg) { + var absPath = path.resolve(arg); - fs.stat(absPath, function(err, stat) { - if (err) throw err; + fs.stat(absPath, function(err, stat) { + if (err) throw err; - if (stat.isFile()) { - transformFile(absPath); - } else if (stat.isDirectory()) { - var exclude = null; - if (argv.exclude) { - exclude = new RegExp(argv.exclude); + if (stat.isFile()) { + transformFile(absPath); + } else if (stat.isDirectory()) { + var exclude = null; + if (argv.exclude) { + exclude = new RegExp(argv.exclude); + } + transformDir(absPath, exclude); + } else { + throw new Error('Unknown filesystem node type: ' + absPath); } - transformDir(absPath, exclude); - } else { - throw new Error('Unknown filesystem node type: ' + absPath); - } + }); }); }