Files
maven-settings-action/index.js
Slawomir Jaranowski bcf2e289fb windows home directory
2019-10-03 09:06:12 +02:00

36 lines
867 B
JavaScript

const core = require('@actions/core');
const path = require('path');
const fs = require('fs');
const os = require('os');
const settings = require('./settings');
// most @actions toolkit packages have async methods
async function run() {
try {
const settingsPath = path.join(os.homedir(), '.m2', 'settings.xml');
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 };