1
0
Fork 0
mirror of https://github.com/shimataro/ssh-key-action.git synced 2025-06-19 22:52:10 +10:00

Fix known_host clobbering

This commit is contained in:
Jack Tuck 2020-08-13 19:50:22 +01:00 committed by Jack Tuck
parent c6c7de11ed
commit fcf6fdad1c
3 changed files with 31 additions and 3 deletions

View file

@ -43,7 +43,7 @@ function main() {
},
{
name: "known_hosts",
contents: prependLf(core.getInput("known_hosts", {
contents: appendLf(core.getInput("known_hosts", {
required: true,
})),
options: {
@ -102,6 +102,18 @@ function getHomeEnv() {
// macOS / Linux
return "HOME";
}
/**
* append LF to value if not empty
* @param value the value to append LF
* @returns prepended value
*/
function appendLf(value) {
if (value.length === 0) {
// do nothing if empty
return "";
}
return `${value}\n`;
}
/**
* prepend LF to value if not empty
* @param value the value to prepend LF