From 2a6d2e6cead22c00fcff3795e5b27347e2e2a881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Tue, 31 Mar 2020 16:58:44 +0200 Subject: [PATCH] fixes #423 --- src/publish.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/publish.ts b/src/publish.ts index 3c7d7266..3375e877 100644 --- a/src/publish.ts +++ b/src/publish.ts @@ -99,11 +99,17 @@ export interface IPublishOptions { ignoreFile?: string; } -function versionBump(cwd: string = process.cwd(), version?: string, commitMessage?: string): Promise { +async function versionBump(cwd: string = process.cwd(), version?: string, commitMessage?: string): Promise { if (!version) { return Promise.resolve(null); } + const manifest = await readManifest(cwd); + + if (manifest.version === version) { + return null; + } + switch (version) { case 'major': case 'minor': @@ -127,14 +133,15 @@ function versionBump(cwd: string = process.cwd(), version?: string, commitMessag command = `${command} -m "${commitMessage}"`; } - // call `npm version` to do our dirty work - return exec(command, { cwd }) - .then(({ stdout, stderr }) => { - process.stdout.write(stdout); - process.stderr.write(stderr); - return Promise.resolve(null); - }) - .catch(err => Promise.reject(err.message)); + try { + // call `npm version` to do our dirty work + const { stdout, stderr } = await exec(command, { cwd }); + process.stdout.write(stdout); + process.stderr.write(stderr); + return null; + } catch (err) { + throw err.message; + } } export function publish(options: IPublishOptions = {}): Promise {