1
0
Fork 0
mirror of https://github.com/actions/setup-java synced 2024-11-09 23:22:40 +00:00

generated and pretty files

This commit is contained in:
Bryan Clark 2019-11-28 12:40:45 -08:00
parent b0e5cf270d
commit dc5f78f54d
4 changed files with 16 additions and 9 deletions

View file

@ -22,14 +22,14 @@ const core = __importStar(require("@actions/core"));
const io = __importStar(require("@actions/io")); const io = __importStar(require("@actions/io"));
exports.M2_DIR = '.m2'; exports.M2_DIR = '.m2';
exports.SETTINGS_FILE = 'settings.xml'; exports.SETTINGS_FILE = 'settings.xml';
function configAuthentication(username, password) { function configAuthentication(id, username, password) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (username && password) { if (id && username && password) {
core.debug(`configAuthentication with ${username} and a password`); core.debug(`configAuthentication with ${username} and a password`);
const directory = path.join(os.homedir(), exports.M2_DIR); const directory = path.join(os.homedir(), exports.M2_DIR);
yield io.mkdirP(directory); yield io.mkdirP(directory);
core.debug(`created directory ${directory}`); core.debug(`created directory ${directory}`);
yield write(directory, generate(username, password)); yield write(directory, generate(id, username, password));
} }
else { else {
core.debug(`no auth without username: ${username} and password: ${password}`); core.debug(`no auth without username: ${username} and password: ${password}`);
@ -38,11 +38,12 @@ function configAuthentication(username, password) {
} }
exports.configAuthentication = configAuthentication; exports.configAuthentication = configAuthentication;
// only exported for testing purposes // only exported for testing purposes
function generate(username, password) { function generate(id, username, password) {
return ` return `
<settings> <settings>
<servers> <servers>
<server> <server>
<id>${id}</id>
<username>${username}</username> <username>${username}</username>
<password>${password}</password> <password>${password}</password>
</server> </server>

View file

@ -29,11 +29,14 @@ function run() {
const arch = core.getInput('architecture', { required: true }); const arch = core.getInput('architecture', { required: true });
const jdkFile = core.getInput('jdkFile', { required: false }) || ''; const jdkFile = core.getInput('jdkFile', { required: false }) || '';
yield installer.getJava(version, arch, jdkFile); yield installer.getJava(version, arch, jdkFile);
const username = core.getInput('username', { required: false });
const password = core.getInput('password', { required: false });
yield auth.configAuthentication(username, password);
const matchersPath = path.join(__dirname, '..', '.github'); const matchersPath = path.join(__dirname, '..', '.github');
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
const id = core.getInput('id', { required: false });
const username = core.getInput('username', { required: false });
const password = core.getInput('password', { required: false });
if (id && username && password) {
yield auth.configAuthentication(id, username, password);
}
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);

View file

@ -7,7 +7,11 @@ import * as io from '@actions/io';
export const M2_DIR = '.m2'; export const M2_DIR = '.m2';
export const SETTINGS_FILE = 'settings.xml'; export const SETTINGS_FILE = 'settings.xml';
export async function configAuthentication(id: string, username: string, password: string) { export async function configAuthentication(
id: string,
username: string,
password: string
) {
if (id && username && password) { if (id && username && password) {
core.debug(`configAuthentication with ${username} and a password`); core.debug(`configAuthentication with ${username} and a password`);
const directory: string = path.join(os.homedir(), M2_DIR); const directory: string = path.join(os.homedir(), M2_DIR);

View file

@ -25,7 +25,6 @@ async function run() {
if (id && username && password) { if (id && username && password) {
await auth.configAuthentication(id, username, password); await auth.configAuthentication(id, username, password);
} }
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }