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

Should allow non-zero exit code when generating graph #294

Open
f4irline opened this issue Sep 27, 2021 · 3 comments
Open

Should allow non-zero exit code when generating graph #294

f4irline opened this issue Sep 27, 2021 · 3 comments
Labels

Comments

@f4irline
Copy link

I have a use case where I'm running madge in CI to check for circular dependencies. I just noticed that if you generate the dependency graph when checking for circular dependencies, madge returns exit code 0 even if there are circular dependencies. Probably because generating the image graph returns exit code 0 when the graph is generated successfully, and 1 if generating the image fails?

Could we add a flag or something to the CLI to make madge optionally exit with non-zero exit code even when generating the graph, if circular dependencies are found?

@f4irline
Copy link
Author

I have a use case where I'm running madge in CI to check for circular dependencies. I just noticed that if you generate the dependency graph when checking for circular dependencies, madge returns exit code 0 even if there are circular dependencies. Probably because generating the image graph returns exit code 0 when the graph is generated successfully, and 1 if generating the image fails?

Could we add a flag or something to the CLI to make madge optionally exit with non-zero exit code even when generating the graph, if circular dependencies are found?

I'm also happy to contribute and see if I'm able to implement the flag, if this sounds reasonable 🙂

@Smrtnyk
Copy link

Smrtnyk commented Dec 28, 2021

you can do it also yourself

(async () => {
    const deps = await madge("<some-path>", CONFIG).then((res) => res.circular());
    console.log(`Detected ${deps.length} circular deps.`);
    console.log(util.inspect(deps.map(formatCircularItem)));
    if (deps.length > ALLOWED_CIRCULAR_DEPS) {
        console.error("Detected more circular deps than allowed. Exiting process.");
        process.exit(1);
    }
})();

@PabloLION
Copy link
Collaborator

I'm also happy to contribute and see if I'm able to implement the flag, if this sounds reasonable

It does sound reasonable to me. PRs are welcomed and appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants