From 1e43983a203d7c437e4443074fe063670a0c3ba9 Mon Sep 17 00:00:00 2001 From: Greg Fenton Date: Sat, 15 Jul 2023 17:44:36 -0400 Subject: [PATCH] FEAT: add `--exit-code` & default to `0` This is a BREAKING CHANGE. The previous default was `1`, that is contrary to expected behaviours. To get the previous behaviour, simply specify "--exit-code 1" or "-x 1" --- bin/generate-schema | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/generate-schema b/bin/generate-schema index e60bfc4..e10943a 100755 --- a/bin/generate-schema +++ b/bin/generate-schema @@ -11,6 +11,7 @@ var content = '' var mode = 'json' var quiet = false var file = null +var exitCode = 0 // Setup CLI cli.version(pkg.version) @@ -44,12 +45,21 @@ cli.option('-c, --clickhouse', 'ClickHouse Table Schema output', function () { mode = 'clickhouse' }) +cli.option('-x, --exit-code ', 'Process exit code to use for successful execution', function () { + exitCode = 0 +}) + cli.action(function (filename) { file = filename }) cli.parse(process.argv) +var options = cli.opts(); +if (options.exitCode) { + exitCode = options.exitCode; +} + // Program function evaluate (data) { @@ -105,7 +115,7 @@ var stream = process.stdin if (file) { stream = fs.createReadStream(file) stream.on('close', function () { - process.exit(1) + process.exit(exitCode) }) }