add --ignore and --extensions flag to 6to5-node to compliment require hook options
This commit is contained in:
parent
5b08924c02
commit
45c8c29cdf
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
var commander = require("commander");
|
var commander = require("commander");
|
||||||
var Module = require("module");
|
var Module = require("module");
|
||||||
var path = require("path");
|
|
||||||
var util = require("../lib/6to5/util");
|
var util = require("../lib/6to5/util");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
var repl = require("repl");
|
var repl = require("repl");
|
||||||
@ -12,13 +11,29 @@ var _ = require("lodash");
|
|||||||
|
|
||||||
commander.option("-e, --eval [script]", "evaluate script");
|
commander.option("-e, --eval [script]", "evaluate script");
|
||||||
commander.option("-p, --print", "evaluate script and print result");
|
commander.option("-p, --print", "evaluate script and print result");
|
||||||
|
commander.option("-i, --ignore [regex]", "ignore all files that match this regex when using the require hook");
|
||||||
|
commander.option("-x, --extensions [extensions]", "list of extensions to hook into [.es6,.js]", util.list);
|
||||||
|
|
||||||
var pkg = require("../package.json");
|
var pkg = require("../package.json");
|
||||||
commander.version(pkg.version);
|
commander.version(pkg.version);
|
||||||
commander.usage("[options] [ -e script | script.js ] [arguments]");
|
commander.usage("[options] [ -e script | script.js ] [arguments]");
|
||||||
commander.parse(process.argv);
|
commander.parse(process.argv);
|
||||||
|
|
||||||
to5.register();
|
//
|
||||||
|
|
||||||
|
var registerOpts = {};
|
||||||
|
|
||||||
|
if (commander.ignore) {
|
||||||
|
registerOpts.ignoreRegex = new RegExp(commander.ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commander.extensions && commander.extensions.length) {
|
||||||
|
registerOpts.extensions = commander.extensions
|
||||||
|
}
|
||||||
|
|
||||||
|
to5.register(registerOpts);
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
var _eval = function (code, filename) {
|
var _eval = function (code, filename) {
|
||||||
code = to5.transform(code, { filename: filename }).code;
|
code = to5.transform(code, { filename: filename }).code;
|
||||||
|
|||||||
@ -5,6 +5,8 @@ var sourceMap = require("source-map");
|
|||||||
var transform = require("../../lib/6to5/transform");
|
var transform = require("../../lib/6to5/transform");
|
||||||
var chokidar = require("chokidar");
|
var chokidar = require("chokidar");
|
||||||
var mkdirp = require("mkdirp");
|
var mkdirp = require("mkdirp");
|
||||||
|
var util2 = require("../../lib/6to5/util");
|
||||||
|
var util = require("./util");
|
||||||
var path = require("path");
|
var path = require("path");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
@ -14,12 +16,8 @@ commander.option("-s, --source-maps", "Save source map alongside the compiled co
|
|||||||
commander.option("-f, --filename [filename]", "Filename to use when reading from stdin - this will be used in source-maps, errors etc [stdin]", "stdin");
|
commander.option("-f, --filename [filename]", "Filename to use when reading from stdin - this will be used in source-maps, errors etc [stdin]", "stdin");
|
||||||
commander.option("-w, --watch", "Recompile files on changes");
|
commander.option("-w, --watch", "Recompile files on changes");
|
||||||
|
|
||||||
var list = function (val) {
|
commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util2.list);
|
||||||
return val ? val.split(",") : [];
|
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util2.list);
|
||||||
};
|
|
||||||
|
|
||||||
commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", list);
|
|
||||||
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", list);
|
|
||||||
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
|
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
|
||||||
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
|
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,10 @@ var _ = require("lodash");
|
|||||||
|
|
||||||
exports.util = require("./util");
|
exports.util = require("./util");
|
||||||
|
|
||||||
exports.register = function () {
|
exports.register = function (opts) {
|
||||||
return require("./register");
|
var register = require("./register");
|
||||||
|
if (opts != null) register(opts);
|
||||||
|
return register;
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.polyfill = function () {
|
exports.polyfill = function () {
|
||||||
|
|||||||
@ -20,6 +20,10 @@ exports.ensureBlock = function (node) {
|
|||||||
node.body = b.blockStatement(block);
|
node.body = b.blockStatement(block);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.list = function (val) {
|
||||||
|
return val ? val.split(",") : [];
|
||||||
|
};
|
||||||
|
|
||||||
exports.getUid = function (parent, file) {
|
exports.getUid = function (parent, file) {
|
||||||
var node;
|
var node;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user