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:
parent
c6c7de11ed
commit
fcf6fdad1c
3 changed files with 31 additions and 3 deletions
14
lib/main.js
14
lib/main.js
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue