diff --git a/src/common/SetProjectReferencesOptions.ts b/src/common/SetProjectReferencesOptions.ts index 0a8461f..336a946 100644 --- a/src/common/SetProjectReferencesOptions.ts +++ b/src/common/SetProjectReferencesOptions.ts @@ -2,4 +2,5 @@ export interface SetProjectReferencesOptions { root: string save: boolean indentationTsConfig: string | undefined + useExitCode: boolean } diff --git a/src/index.ts b/src/index.ts index f655706..aea82b0 100755 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import fs from 'fs' import program from 'commander' import path from 'path' import { - difference, isEqual, merge, sortBy + difference, isEqual, merge, sortBy, } from 'lodash' import JSON from 'comment-json' import { version } from './package.json' @@ -176,6 +176,10 @@ function setProjectReferences(options: SetProjectReferencesOptions): void { saveTsConfigJson, options, }) + + if (!everythingIsFine && options.useExitCode) { + process.exitCode = 1 + } } program.version(version) @@ -184,6 +188,7 @@ program .option('-r, --root ', 'path to the root of monorepo', process.cwd()) .option('-s, --save', 'write changes to the files', false) .option('-t, --indentation-ts-config ', `indentation of tsconfig.json. Use $'\\t' for a tab`) + .option('-e, --use-exit-code', 'return a non-zero exit code if there are any discrepancies', false) .action(setProjectReferences) program.parse(process.argv)