From 1af1d7edfae77c7fb22f266ee472193817ed14d6 Mon Sep 17 00:00:00 2001 From: Victor Afanassieff Date: Sat, 28 May 2022 23:00:45 +0200 Subject: [PATCH] feat: stop loging twice --- bin/index.js | 19 ++++++++++++++++--- package.json | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bin/index.js b/bin/index.js index 4842791..dff067e 100755 --- a/bin/index.js +++ b/bin/index.js @@ -2,7 +2,10 @@ import 'zx/globals' import console from 'node:console' +import fs from 'node:fs/promises' +import path from 'node:path' import process from 'node:process' +import { URL } from 'node:url' import { Command } from 'commander' @@ -18,6 +21,12 @@ const provider = new Command('provider') $.verbose = false +const { version } = await fs + .readFile( + path.join(new URL('.', import.meta.url).pathname, '../package.json') + ) + .then(JSON.parse) + provider .command('configure') .description('Configure a provider') @@ -30,7 +39,7 @@ provider .argument('', 'Provider to use') .action(set) -program.name('email-alias').description('Manage email alias').version('0.1.0') +program.name('email-alias').description('Manage email alias').version(version) program.command('list').description('List current alias').action(list) @@ -54,6 +63,10 @@ program.exitOverride() try { await program.parseAsync(process.argv) } catch (error) { - console.error(error.message) - process.exit(-1) + if (error.constructor.name === 'CommanderError') { + process.exit(error.exitCode) + } else { + console.error(error.message) + process.exit(-1) + } } diff --git a/package.json b/package.json index f534a1f..0104ca2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vafanassieff/email-alias", - "version": "0.1.2", + "version": "0.1.3", "description": "Create a email alias to keep you real email hidden !", "main": "src/index.js", "repository": {