Skip to content

Commit

Permalink
Disable progress bars when running in CI or non-interactive shell (#798)
Browse files Browse the repository at this point in the history
Fixes #447
  • Loading branch information
evocateur committed May 1, 2017
1 parent 8dbdbe8 commit bb7cbf3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -46,6 +46,7 @@
"globby": "^6.1.0",
"graceful-fs": "^4.1.11",
"inquirer": "^3.0.6",
"is-ci": "^1.0.10",
"load-json-file": "^2.0.0",
"lodash": "^4.17.4",
"minimatch": "^3.0.0",
Expand Down
9 changes: 1 addition & 8 deletions src/UpdatedPackagesCollector.js
Expand Up @@ -82,10 +82,9 @@ export default class UpdatedPackagesCollector {
}

const updatedPackages = {};
const tracker = this.logger.newItem("find updated packages");

const registerUpdated = (pkg) => {
this.logger.verbose("has update", pkg.name);
this.logger.verbose("updated", pkg.name);
updatedPackages[pkg.name] = pkg;
};

Expand All @@ -94,11 +93,7 @@ export default class UpdatedPackagesCollector {
if (!hasTags || forced.has("*")) {
this.packages.forEach(registerUpdated);
} else {
tracker.addWork(this.packages.length);

this.packages.filter((pkg) => {
tracker.completeWork(1);

if (forced.has(pkg.name)) {
return true;
} else {
Expand All @@ -107,8 +102,6 @@ export default class UpdatedPackagesCollector {
}).forEach(registerUpdated);
}

tracker.finish();

return updatedPackages;
}

Expand Down
10 changes: 7 additions & 3 deletions src/cli.js
@@ -1,4 +1,5 @@
import dedent from "dedent";
import isCI from "is-ci";
import log from "npmlog";
import yargs from "yargs/yargs";

Expand All @@ -21,9 +22,12 @@ export default function CLI(argv, cwd) {
"version",
]);

if (process.stdout.isTTY) {
// log.enableColor();
// log.enableUnicode();
if (isCI || !process.stderr.isTTY) {
log.disableColor();
log.disableProgress();
} else if (process.stderr.isTTY) {
log.enableColor();
log.enableUnicode();
log.enableProgress();
}

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -2045,7 +2045,7 @@ is-builtin-module@^1.0.0:
dependencies:
builtin-modules "^1.0.0"

is-ci@^1.0.9:
is-ci@^1.0.10, is-ci@^1.0.9:
version "1.0.10"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.0.10.tgz#f739336b2632365061a9d48270cd56ae3369318e"
dependencies:
Expand Down

0 comments on commit bb7cbf3

Please sign in to comment.