From 4e1b9e0a2eb26e1e458e3593f04d6c8366e5db70 Mon Sep 17 00:00:00 2001 From: Uladzimir Havenchyk Date: Mon, 4 Oct 2021 22:22:01 +0300 Subject: [PATCH] Allow updating npm lockfile v2 with the new version --- action.yml | 4 ++++ index.js | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/action.yml b/action.yml index d28b671..7f5b0a1 100644 --- a/action.yml +++ b/action.yml @@ -54,6 +54,10 @@ inputs: description: 'Set to false to skip pushing the new tag' default: 'true' required: false + bump_package-lock: + description: 'Set to false to skip bumping version in lockfile version 2' + default: 'true' + required: false outputs: newTag: description: 'The newly created tag' diff --git a/index.js b/index.js index ee0a141..b297119 100644 --- a/index.js +++ b/index.js @@ -157,6 +157,17 @@ const workspace = process.env.GITHUB_WORKSPACE; newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString().trim().replace(/^v/, ''); newVersion = `${tagPrefix}${newVersion}`; console.log(`::set-output name=newTag::${newVersion}`); + + // case: when user wants to skip updating package-lock.json v2 + try { + const bumpPackageLock = process.env['INPUT_BUMP_PACKAGE-LOCK'] + if (bumpPackageLock) { + await runInWorkspace('npm', ['install', '--package-lock-only', '--ignore-scripts']) + } + } catch(e) { + logError(e); + } + try { // to support "actions/checkout@v1" await runInWorkspace('git', ['commit', '-a', '-m', commitMessage.replace(/{{version}}/g, newVersion)]);