diff --git a/src/bump-dependencies.js b/src/bump-dependencies.js index c1f551a1..a0941db8 100644 --- a/src/bump-dependencies.js +++ b/src/bump-dependencies.js @@ -15,6 +15,7 @@ const { } = require('./updatees/package'); const updateDockerfile = require('./updatees/dockerfile'); const {commitFiles, currentUser} = require('./core/git'); +const {executeScript} = require('./core/script'); const {syncGithub} = require('./core/github'); const {findLatest} = require('./core/node'); const {makeError, formatEventualSuffix} = require('./core/utils'); @@ -22,7 +23,7 @@ const {makeError, formatEventualSuffix} = require('./core/utils'); const bumpNodeVersion = async (latestNode, config) => { process.stdout.write(c.bold.blue(`\n\n⬆️ About to bump node version:\n`)); const {exact, loose} = config.node; - const {scope} = config.argv; + const {scope, preCommitBumpCommand, runNpmInstall} = config.argv; const nodeVersion = _.trimCharsStart('v', latestNode.version); await Promise.all([ updateServerless(nodeVersion, config.node.serverless), @@ -32,6 +33,10 @@ const bumpNodeVersion = async (latestNode, config) => { updateDockerfile(nodeVersion, config.node.dockerfile), config.lernaMonorepo && updateLearnaPackageEngines(nodeVersion, latestNode.npm, {exact, loose}) ]); + // Post commands to synchronise the package-lock.json + // eslint-disable-next-line no-template-curly-in-string + if (runNpmInstall) await executeScript(['. ${NVM_DIR:-$HOME/.nvm}/nvm.sh && nvm use', 'npm i']); + if (!_.isEmpty(preCommitBumpCommand)) await executeScript(preCommitBumpCommand); const messageSuffix = formatEventualSuffix(config.argv.message); diff --git a/src/index.js b/src/index.js index a46c37b8..c66472f4 100644 --- a/src/index.js +++ b/src/index.js @@ -129,6 +129,18 @@ const yargs = require('yargs') boolean: true, alias: 'c' }) + .option('run-npm-install', { + describe: 'Command to run before to commit (disable with --no-run-npm-install)', + boolean: true, + alias: 'i', + default: true + }) + .option('pre-commit-bump-command', { + describe: 'Command to run before to commit (changes will be commited)', + string: true, + alias: 'b', + array: true + }) .option('pre-clean-command', { describe: 'Run before to clean state', string: true,