diff --git a/bin/cli.js b/bin/cli.js index 86b67dd7..99b53370 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -35,6 +35,7 @@ program .option('--include-npm', 'include shallow NPM modules', false) .option('--no-color', 'disable color in output and image', false) .option('--no-spinner', 'disable progress spinner', false) + .option('--no-count', 'disable circular dependencies counting', false) .option('--stdin', 'read predefined tree from STDIN', false) .option('--warning', 'show warnings about skipped files', false) .option('--debug', 'turn on debugĀ output', false) @@ -258,7 +259,8 @@ function createOutputFromOptions(program, res) { const circular = res.circular(); output.circular(spinner, res, circular, { - json: program.json + json: program.json, + printCount: program.count }); if (circular.length) { diff --git a/lib/output.js b/lib/output.js index 7f2269ac..39e5a75c 100644 --- a/lib/output.js +++ b/lib/output.js @@ -80,7 +80,9 @@ module.exports.circular = function (spinner, res, circular, opts) { } else { spinner.fail(chalk.red.bold(`Found ${pluralize('circular dependency', cyclicCount, true)}!\n`)); circular.forEach((path, idx) => { - process.stdout.write(chalk.dim(idx + 1 + ') ')); + if (opts.printCount) { + process.stdout.write(chalk.dim(idx + 1 + ') ')); + } path.forEach((module, idx) => { if (idx) { process.stdout.write(chalk.dim(' > ')); diff --git a/test/output.sh b/test/output.sh index 7db0058d..4731daa1 100755 --- a/test/output.sh +++ b/test/output.sh @@ -1,7 +1,7 @@ -#!/bin/sh +#!/bin/bash function desc() { - echo "\033[01;38;5;022m############### $1 ###############\033[0m"; + echo "\033[01;38;5;022m############### $1 ###############\033[0m" } desc "LIST" @@ -16,7 +16,10 @@ desc "DEPENDS" desc "CIRCULAR (OK)" ./bin/cli.js test/cjs/a.js -c -desc "CIRCULAR (FOUND)" +desc "CIRCULAR (FOUND, NO INDEX COUNTING)" +./bin/cli.js test/cjs/circular/a.js -c --no-count + +desc "CIRCULAR (FOUND, WITH INDEX COUNT)" ./bin/cli.js test/cjs/circular/a.js -c desc "NPM" @@ -52,4 +55,4 @@ desc "ERROR" desc "DEBUG" ./bin/cli.js lib/log.js --debug -exit 0 \ No newline at end of file +exit 0