From a944c106a0f1a9b1758cf184ef9740355db502cf Mon Sep 17 00:00:00 2001 From: Hieu Pham Date: Fri, 18 Mar 2022 09:10:39 +0700 Subject: [PATCH] Allow running npm version with arg --allow-same-version --- docs/npm.md | 4 ++++ lib/plugin/npm/npm.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/npm.md b/docs/npm.md index ac5ab7f8..d4390ac6 100644 --- a/docs/npm.md +++ b/docs/npm.md @@ -94,6 +94,10 @@ basically defeats the purpose of 2FA (also, the OTP expires after a short period Use `npm.publishPath` to publish only a specific folder. For example, set `npm.publishPath` to `"dist"`. The default value is the current (root) folder (`"."`). +## Allow same version + +Use `npm.allowSameVersion` to prevent throwing error when setting the new version to the same value as the current version. + ## Monorepos Monorepos do not require extra configuration, but release-it handles only one package at a time. Also see how diff --git a/lib/plugin/npm/npm.js b/lib/plugin/npm/npm.js index 48983675..fde5d731 100644 --- a/lib/plugin/npm/npm.js +++ b/lib/plugin/npm/npm.js @@ -82,7 +82,8 @@ class npm extends Plugin { if (!this.config.isIncrement) return false; - const task = () => this.exec(`npm version ${version} --no-git-tag-version`); + const allowSameVersion = this.options.allowSameVersion || false; + const task = () => this.exec(['npm', 'version', version, '--no-git-tag-version', allowSameVersion ? '--allow-same-version' : undefined]); return this.spinner.show({ task, label: 'npm version' }); }