Skip to content

Commit

Permalink
fix(progress): Correctly avoid progress where we don't want it
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Dec 31, 2018
1 parent 8957648 commit 0de3df9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions commands/bootstrap/index.js
Expand Up @@ -119,6 +119,8 @@ class BootstrapCommand extends Command {
const filteredLength = this.filteredPackages.length;
const packageCountLabel = `${filteredLength} package${filteredLength > 1 ? "s" : ""}`;

// root install does not need progress bar
this.enableProgressBar();
this.logger.info("", `Bootstrapping ${packageCountLabel}`);

const tasks = [
Expand Down
2 changes: 2 additions & 0 deletions commands/clean/index.js
Expand Up @@ -44,6 +44,8 @@ class CleanCommand extends Command {
}

execute() {
this.enableProgressBar();

const tracker = this.logger.newItem("clean");
const mapper = dirPath => {
tracker.info("clean", "removing", dirPath);
Expand Down
2 changes: 2 additions & 0 deletions commands/import/index.js
Expand Up @@ -186,6 +186,8 @@ class ImportCommand extends Command {
}

execute() {
this.enableProgressBar();

const tracker = this.logger.newItem("execute");
const mapper = sha => {
tracker.info(sha);
Expand Down
1 change: 1 addition & 0 deletions commands/publish/index.js
Expand Up @@ -164,6 +164,7 @@ class PublishCommand extends Command {
}

execute() {
this.enableProgressBar();
this.logger.info("publish", "Publishing packages to npm...");

let chain = Promise.resolve();
Expand Down
14 changes: 8 additions & 6 deletions core/command/index.js
Expand Up @@ -183,7 +183,7 @@ class Command {
}

configureLogging() {
const { loglevel, progress = true } = this.options;
const { loglevel } = this.options;

if (loglevel) {
log.level = loglevel;
Expand All @@ -192,11 +192,6 @@ class Command {
// handle log.success()
log.addLevel("success", 3001, { fg: "green", bold: true });

/* istanbul ignore next */
if (progress) {
log.enableProgress();
}

// create logger that subclasses use
Object.defineProperty(this, "logger", {
value: log.newGroup(this.name),
Expand All @@ -206,6 +201,13 @@ class Command {
log.resume();
}

enableProgressBar() {
/* istanbul ignore next */
if (this.options.progress !== false) {
log.enableProgress();
}
}

gitInitialized() {
const opts = {
cwd: this.project.rootPath,
Expand Down

0 comments on commit 0de3df9

Please sign in to comment.