Introduce --remove-comments (-c) option

This commit is contained in:
Lars Kappert 2014-11-16 20:28:39 +01:00
parent 3815913537
commit e1cc1dcb4b
3 changed files with 6 additions and 3 deletions

View File

@ -17,6 +17,7 @@ commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ON
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list); commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.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");
commander.option("-c, --remove-comments", "Remove comments from the compiled code", false);
commander.on("--help", function(){ commander.on("--help", function(){
var outKeys = function (title, obj) { var outKeys = function (title, obj) {
@ -89,7 +90,8 @@ exports.opts = {
whitelist: commander.whitelist, whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline, sourceMap: commander.sourceMaps || commander.sourceMapsInline,
runtime: commander.runtime, runtime: commander.runtime,
modules: commander.modules modules: commander.modules,
comments: !commander.removeComments
}; };
var fn; var fn;

View File

@ -32,7 +32,8 @@ File.normaliseOptions = function (opts) {
filename: "unknown", filename: "unknown",
modules: "common", modules: "common",
runtime: false, runtime: false,
code: true code: true,
comments: true
}); });
// normalise windows path separators to unix // normalise windows path separators to unix

View File

@ -17,7 +17,7 @@ var _ = require("lodash");
function CodeGenerator(ast, opts, code) { function CodeGenerator(ast, opts, code) {
opts = opts || {}; opts = opts || {};
this.comments = ast.comments || []; this.comments = opts.comments ? (ast.comments || []) : [];
this.tokens = ast.tokens || []; this.tokens = ast.tokens || [];
this.format = CodeGenerator.normaliseOptions(opts); this.format = CodeGenerator.normaliseOptions(opts);
this.ast = ast; this.ast = ast;