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:
parent
7952ff5445
commit
ab2b5fa346
3 changed files with 35 additions and 9 deletions
23
src/main.ts
23
src/main.ts
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue