Address latest review feedback

This commit is contained in:
Bryan Clark 2019-12-19 08:52:26 -08:00
parent 998be8d08f
commit 6924f73ee0
6 changed files with 390 additions and 387 deletions

View file

@ -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'
});
}

View file

@ -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);