Files
maven-settings-action/index.js
Slawomir Jaranowski d715271c3a home path on windows
2019-10-03 07:55:31 +02:00

41 lines
972 B
JavaScript

const core = require('@actions/core');
const path = require('path');
const fs = require('fs');
const settings = require('./settings');
// most @actions toolkit packages have async methods
async function run() {
try {
var settingsPath;
try {
settingsPath= path.join(process.env['HOME'], '.m2', 'settings.xml');
} catch (error) {
console.log("HOME=" + process.env['HOME']);
throw error;
}
core.info('Prepare maven setings: ' + settingsPath);
if (fs.existsSync(settingsPath)) {
core.warning('maven settings.xml already exists - skip');
return;
}
const templateXml = settings.getSettingsTemplate();
settings.fillServers(templateXml);
settings.fillProperties(templateXml);
settings.addSonatypeSnapshots(templateXml);
settings.writeSettings(settingsPath, templateXml);
} catch (error) {
core.setFailed(error.message);
console.error(error);
}
}
run();
module.exports = { run };