Files
maven-settings-action/index.js

36 lines
867 B
JavaScript
Raw Normal View History

2019-10-01 22:14:15 +02:00
const core = require('@actions/core');
const path = require('path');
const fs = require('fs');
2019-10-03 09:06:12 +02:00
const os = require('os');
2019-10-01 22:14:15 +02:00
const settings = require('./settings');
// most @actions toolkit packages have async methods
async function run() {
try {
2019-10-03 09:06:12 +02:00
const settingsPath = path.join(os.homedir(), '.m2', 'settings.xml');
2019-10-03 07:55:31 +02:00
core.info('Prepare maven setings: ' + settingsPath);
2019-10-01 22:14:15 +02:00
2019-10-03 07:55:31 +02:00
if (fs.existsSync(settingsPath)) {
2019-10-01 22:14:15 +02:00
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);
2019-10-01 22:25:13 +02:00
console.error(error);
2019-10-01 22:14:15 +02:00
}
}
run();
module.exports = { run };