mirror of
https://github.com/actions/setup-java.git
synced 2025-04-20 01:46:46 +00:00
Address latest review feedback
This commit is contained in:
parent
998be8d08f
commit
6924f73ee0
6 changed files with 390 additions and 387 deletions
22
src/auth.ts
22
src/auth.ts
|
@ -57,19 +57,15 @@ export function generate(id: string, username: string, password: string) {
|
|||
}
|
||||
|
||||
async function write(directory: string, settings: string) {
|
||||
const options = {encoding: 'utf-8', flag: 'wx'}; // 'wx': Like 'w' but fails if path exists
|
||||
const location = path.join(directory, SETTINGS_FILE);
|
||||
console.log(`writing ${location}`);
|
||||
try {
|
||||
return fs.writeFileSync(location, settings, options);
|
||||
} catch (e) {
|
||||
if (e.code == 'EEXIST') {
|
||||
console.warn(`overwriting existing file ${location}`);
|
||||
return fs.writeFileSync(location, settings, {
|
||||
encoding: 'utf-8',
|
||||
flag: 'w'
|
||||
});
|
||||
}
|
||||
throw e;
|
||||
if (fs.existsSync(location)) {
|
||||
console.warn(`overwriting existing file ${location}`);
|
||||
} else {
|
||||
console.log(`writing ${location}`);
|
||||
}
|
||||
|
||||
return fs.writeFileSync(location, settings, {
|
||||
encoding: 'utf-8',
|
||||
flag: 'w'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,11 +19,13 @@ async function run() {
|
|||
console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||
|
||||
const id = core.getInput('server-id', {required: false});
|
||||
const username = core.getInput('username', {required: false});
|
||||
const password = core.getInput('password', {required: false});
|
||||
const username = core.getInput('server-username', {required: false});
|
||||
const password = core.getInput('server-password', {required: false});
|
||||
|
||||
if (id && username && password) {
|
||||
await auth.configAuthentication(id, username, password);
|
||||
} else if (id || username || password) {
|
||||
console.warn('All 3 server-(id, username, and password) are required.');
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue