Skip to content

Commit

Permalink
fix: add check to test if mvn can be executed
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed Dec 15, 2022
1 parent 295cfe9 commit 73eedf1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
prepare: require('./src/prepare'),
publish: require('./src/publish')
publish: require('./src/publish'),
verifyConditions: require('./src/verify-conditions')
};
23 changes: 19 additions & 4 deletions src/maven.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
const SemanticReleaseError = require("@semantic-release/error");
const execa = require('execa');

function exec () {
function exec() {
const childProcess = execa(...arguments);
childProcess.stdout.pipe(process.stdout);
childProcess.stderr.pipe(process.stderr);
return childProcess;
}

async function updateVersion (logger, versionStr) {
async function updateVersion(logger, versionStr) {
logger.log(`Updating pom.xml to version ${versionStr}`);
await exec(
'mvn',
['versions:set', '-DgenerateBackupPoms=false', `-DnewVersion=${versionStr}`]
);
}

async function deploy (logger, nextRelease, settingsFile) {
async function deploy(logger, nextRelease, settingsFile) {
logger.log('Deploying version %s with maven', nextRelease.version);
try {
await exec(
Expand All @@ -34,7 +34,22 @@ async function deploy (logger, nextRelease, settingsFile) {
}
}

async function testMvn(logger) {
logger.log('Testing if mvn exists');
try {
await exec(
'mvn',
['-v']
)
} catch (e) {
logger.error('failed to run mvn');
logger.errror(e);
throw new SemanticReleaseError('failed to run mvn');
}
}

module.exports = {
deploy,
updateVersion
updateVersion,
testMvn
};
7 changes: 7 additions & 0 deletions src/verify-conditions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const {
testMvn
} = require("./maven");

module.exports = async function prepare(logger) {
await testMvn(logger);
};

0 comments on commit 73eedf1

Please sign in to comment.