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

* append LF to known_hosts / config (#60)

This commit is contained in:
shimataro 2020-01-18 09:31:29 +09:00 committed by GitHub
parent 7952ff5445
commit ab2b5fa346
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 9 deletions

View file

@ -17,10 +17,9 @@ function main(): void
{
try
{
const name = core.getInput("name");
const files: FileInfo[] = [
{
name: name,
name: core.getInput("name"),
contents: core.getInput("private-key", {
required: true,
}),
@ -31,7 +30,7 @@ function main(): void
},
{
name: "known_hosts",
contents: core.getInput("known-hosts") + "\n",
contents: prependLf(core.getInput("known-hosts")),
options: {
mode: 0o644,
flag: "a",
@ -39,7 +38,7 @@ function main(): void
},
{
name: "config",
contents: core.getInput("config") + "\n",
contents: prependLf(core.getInput("config")),
options: {
mode: 0o644,
flag: "a",
@ -86,4 +85,20 @@ function getHomeDirectory(): string
return home;
}
/**
* prepend LF to value if not empty
* @param value the value to prepend LF
* @returns prepended value
*/
function prependLf(value: string): string
{
if(value.length === 0)
{
// do nothing if empty
return "";
}
return `\n${value}`;
}
main();