Support transforming multiple files at once
Ben Alpert committed
Feb 13, 2014 at 19:14 UTC
cc010e3287ebeadf9e9bd51ffae83e20bbc30b23
1 file changed
+17
-15
npm-jsx_whitespace_transform/run.js
+17
-15
@@ -146,22 +146,24 @@ if (require.main === module) {
146
);
147
}
148
149
- var absPath = path.resolve(argv._[0]);
150
-
151
- fs.stat(absPath, function(err, stat) {
152
- if (err) throw err;
153
-
154
- if (stat.isFile()) {
155
- transformFile(absPath);
156
- } else if (stat.isDirectory()) {
157
- var exclude = null;
158
- if (argv.exclude) {
159
- exclude = new RegExp(argv.exclude);
149
+ argv._.forEach(function(arg) {
150
+ var absPath = path.resolve(arg);
151
+
152
+ fs.stat(absPath, function(err, stat) {
153
+ if (err) throw err;
154
+
155
+ if (stat.isFile()) {
156
+ transformFile(absPath);
157
+ } else if (stat.isDirectory()) {
158
+ var exclude = null;
159
+ if (argv.exclude) {
160
+ exclude = new RegExp(argv.exclude);
161
+ }
162
+ transformDir(absPath, exclude);
163
+ } else {
164
+ throw new Error('Unknown filesystem node type: ' + absPath);
165
}
161
- transformDir(absPath, exclude);
162
- } else {
163
- throw new Error('Unknown filesystem node type: ' + absPath);
164
- }
166
+ });
167
});
168
}
169