add ignore/only option to cli

This commit is contained in:
Sebastian McKenzie
2015-04-04 03:31:19 +11:00
parent c715d96e46
commit 67201e9698
14 changed files with 41 additions and 19 deletions

View File

@@ -28,6 +28,8 @@ module.exports = function (commander, filenames, opts) {
};
var handleFile = function (src, filename) {
if (util.shouldIgnore(src)) return;
if (util.canCompile(filename)) {
write(src, filename);
} else if (commander.copyFiles) {

View File

@@ -107,6 +107,8 @@ module.exports = function (commander, filenames, opts) {
});
_.each(_filenames, function (filename) {
if (!util.shouldIgnore(filename)) return;
results.push(util.compile(filename));
});

View File

@@ -102,12 +102,15 @@ if (errors.length) {
//
exports.opts = {};
var opts = exports.opts = {};
each(options, function (opt, key) {
exports.opts[key] = commander[key];
opts[key] = commander[key];
});
opts.ignore = util.arrayify(opts.ignore, util.regexify);
opts.only = util.arrayify(opts.only, util.regexify);
var fn;
if (commander.outDir) {

View File

@@ -16,6 +16,10 @@ exports.readdir = readdir;
exports.canCompile = util.canCompile;
exports.shouldIgnore = function (loc) {
return util.shouldIgnore(loc, index.opts.ignore, index.opts.only);
};
exports.addSourceMappingUrl = function (code, loc) {
return code + "\n//# sourceMappingURL=" + path.basename(loc);
};
@@ -23,6 +27,8 @@ exports.addSourceMappingUrl = function (code, loc) {
exports.transform = function (filename, code, opts) {
opts = _.defaults(opts || {}, index.opts);
opts.filename = filename;
opts.ignore = null;
opts.only = null;
var result = babel.transform(code, opts);
result.filename = filename;