UNPKG

dependency-cruiser-fork

Version:

Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.

57 lines (51 loc) 1.59 kB
#!/usr/bin/env node const validateNodeEnvironment = require("../src/cli/validate-node-environment"); function formatError(pError) { process.stderr.write(pError.message); process.exitCode = 1; } try { validateNodeEnvironment(); // importing things only after the validateNodeEnv check so we can show an understandable // error. Otherwise, on unsupported platforms we would show a stack trace, which is // not so nice /* eslint-disable node/global-require */ const program = require("commander"); const $package = require("../package.json"); const format = require("../src/cli/format"); program .description( "Format dependency-cruiser output json.\nDetails: https://github.com/sverweij/dependency-cruiser" ) .option( "-f, --output-to <file>", "file to write output to; - for stdout", "-" ) .option( "-T, --output-type <type>", "output type; e.g. err, err-html, dot, ddot, archi or json", "err" ) .option( "-e, --exit-code", "exit with a non-zero exit code when the input json contains error level " + "dependency violations. Works for err, err-long and teamcity output types" ) .version($package.version) .arguments("<dependency-cruiser-json>") .parse(process.argv); if (program.args[0]) { format(program.args[0], program) .then((pExitCode) => { if (program.exitCode) { process.exitCode = pExitCode; } }) .catch(formatError); } else { program.help(); } } catch (pError) { formatError(pError); }