Skip to content

Commit

Permalink
Adds --quiet=false support for #808.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Dec 18, 2019
1 parent 0d18f4d commit 727607c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
14 changes: 11 additions & 3 deletions cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ if (process.env.DEBUG) {
const EleventyErrorHandler = require("./src/EleventyErrorHandler");

try {
const argv = require("minimist")(process.argv.slice(2));
const argv = require("minimist")(process.argv.slice(2), {
boolean: ["quiet"],
default: {
quiet: null
}
});
const Eleventy = require("./src/Eleventy");
const EleventyCommandCheck = require("./src/EleventyCommandCheck");

Expand All @@ -36,6 +41,7 @@ try {
);
});

// TODO refactor to use minimist options.unknown callback?
let cmdCheck = new EleventyCommandCheck(argv);
cmdCheck.hasUnknownArguments();

Expand All @@ -46,8 +52,10 @@ try {
elev.setIncrementalBuild(argv.incremental);
elev.setPassthroughAll(argv.passthroughall);
elev.setFormats(argv.formats);
if (argv.quiet) {
elev.setIsVerbose(false);

// --quiet and --quiet=true resolves to true
if (argv.quiet === true || argv.quiet === false) {
elev.setIsVerbose(!argv.quiet);
}

// careful, we can’t use async/await here to error properly
Expand Down
15 changes: 14 additions & 1 deletion src/Eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ class Eleventy {
*/
this.isVerbose = process.env.DEBUG ? false : !this.config.quietMode;

/**
* @member {Boolean} - Was verbose mode overrode manually?
* @default false
*/
this.isVerboseOverride = false;

/**
* @member {Boolean} - Is Eleventy running in debug mode?
* @default false
Expand Down Expand Up @@ -283,7 +289,6 @@ class Eleventy {

this.writer.setEleventyFiles(this.eleventyFiles);

// TODO maybe isVerbose -> console.log?
debug(`Directories:
Input: ${this.inputDir}
Data: ${this.templateData.getDataDir()}
Expand Down Expand Up @@ -318,6 +323,10 @@ Verbose Output: ${this.isVerbose}`);
setIsVerbose(isVerbose) {
this.isVerbose = !!isVerbose;

// mark that this was changed from the default (probably from --quiet)
// this is used when we reset the config (only applies if not overridden)
this.isVerboseOverride = true;

if (this.writer) {
this.writer.setVerboseOutput(this.isVerbose);
}
Expand Down Expand Up @@ -392,6 +401,10 @@ Arguments:

this.config = config.getConfig();
this.eleventyServe.config = this.config;

if (!this.isVerboseOverride && !process.env.DEBUG) {
this.isVerbose = !this.config.quietMode;
}
}

/**
Expand Down

0 comments on commit 727607c

Please sign in to comment.