Skip to content

Commit

Permalink
Merge pull request #387 from mlostekk/patch-1
Browse files Browse the repository at this point in the history
Adding option to not print the circular file count
  • Loading branch information
PabloLION authored Oct 22, 2023
2 parents 477565b + 9364607 commit 6142cc6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' > '));
Expand Down
11 changes: 7 additions & 4 deletions test/output.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -52,4 +55,4 @@ desc "ERROR"
desc "DEBUG"
./bin/cli.js lib/log.js --debug

exit 0
exit 0

0 comments on commit 6142cc6

Please sign in to comment.