Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option to not print the index #387

Merged
merged 4 commits into from Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion bin/cli.js
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
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
@@ -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