From 5d4dd34e602f9e0e5b71fc623750542a996e4c9f Mon Sep 17 00:00:00 2001 From: Ariel Barmat Date: Sat, 24 Aug 2019 13:41:27 -0300 Subject: [PATCH 1/2] Avoid adding and committing every file when releasing --- lib/bump.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/bump.js b/lib/bump.js index fb4660a..56c21fe 100644 --- a/lib/bump.js +++ b/lib/bump.js @@ -109,7 +109,9 @@ module.exports = async (type, preSuffix) => { createSpinner('Creating release commit'); try { - await runGitCommand(`git add -A && git commit -a -m "${version}"`); + await runGitCommand( + `git add package.json package-lock.json && git commit -m "${version}"` + ); } catch (err) { fail(err.message); } From 418fa4a4b29dfce3489324b25630716144d53953 Mon Sep 17 00:00:00 2001 From: Ariel Barmat Date: Tue, 17 Dec 2019 17:23:34 -0300 Subject: [PATCH 2/2] Commit package-lock.json only if present --- lib/bump.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/bump.js b/lib/bump.js index 56c21fe..f51d9ae 100644 --- a/lib/bump.js +++ b/lib/bump.js @@ -109,8 +109,15 @@ module.exports = async (type, preSuffix) => { createSpinner('Creating release commit'); try { + const commitFiles = ['package.json']; + + const lockfilePath = path.join(process.cwd(), 'package-lock.json'); + if (fs.existsSync(lockfilePath)) { + commitFiles.append('package-lock.json'); + } + await runGitCommand( - `git add package.json package-lock.json && git commit -m "${version}"` + `git add ${commitFiles.join(' ')} && git commit -m "${version}"` ); } catch (err) { fail(err.message);