add ignore/only option to cli
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -107,6 +107,8 @@ module.exports = function (commander, filenames, opts) {
|
||||
});
|
||||
|
||||
_.each(_filenames, function (filename) {
|
||||
if (!util.shouldIgnore(filename)) return;
|
||||
|
||||
results.push(util.compile(filename));
|
||||
});
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user