add quiet option to CLI - fixes #1931

This commit is contained in:
Sebastian McKenzie
2015-07-07 11:26:45 +01:00
parent 4a36a9fb31
commit ec7c40fbf6
4 changed files with 7 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ module.exports = function (commander, filenames) {
outputFileSync(dest, data.code);
console.log(src + " -> " + dest);
util.log(src + " -> " + dest);
};
var handleFile = function (src, filename) {

View File

@@ -135,7 +135,7 @@ module.exports = function (commander, filenames, opts) {
ignoreInitial: true
}).on("all", function (type, filename) {
if (type === "add" || type === "change") {
console.log(type, filename);
util.log(type + " " + filename);
try {
walk();
} catch (err) {

View File

@@ -45,6 +45,7 @@ commander.option("-w, --watch", "Recompile files on changes");
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, --copy-files", "When compiling a directory copy over non-compilable files");
commander.option("-q, --quiet", "Don't log anything");
commander.on("--help", function () {
var outKeys = function (title, obj) {

View File

@@ -25,6 +25,10 @@ exports.addSourceMappingUrl = function (code, loc) {
return code + "\n//# sourceMappingURL=" + path.basename(loc);
};
exports.log = function (msg) {
if (!commander.quiet) console.log(msg);
};
exports.transform = function (filename, code, opts) {
opts = _.defaults(opts || {}, index.opts);
opts.filename = filename;