Skip to content

Commit

Permalink
Perform npm install and add extra command hook 🔏🪝
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrieanKhisbe committed Oct 15, 2024
1 parent 76ebfc1 commit b53d334
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bump-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ 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');

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),
Expand All @@ -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);

Expand Down
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b53d334

Please sign in to comment.