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

@ -15,10 +15,9 @@ const core = __importStar(require("@actions/core"));
*/
function main() {
try {
const name = core.getInput("name");
const files = [
{
name: name,
name: core.getInput("name"),
contents: core.getInput("private-key", {
required: true,
}),
@ -29,7 +28,7 @@ function main() {
},
{
name: "known_hosts",
contents: core.getInput("known-hosts") + "\n",
contents: prependLf(core.getInput("known-hosts")),
options: {
mode: 0o644,
flag: "a",
@ -37,7 +36,7 @@ function main() {
},
{
name: "config",
contents: core.getInput("config") + "\n",
contents: prependLf(core.getInput("config")),
options: {
mode: 0o644,
flag: "a",
@ -74,5 +73,17 @@ function getHomeDirectory() {
}
return home;
}
/**
* prepend LF to value if not empty
* @param value the value to prepend LF
* @returns prepended value
*/
function prependLf(value) {
if (value.length === 0) {
// do nothing if empty
return "";
}
return `\n${value}`;
}
main();
//# sourceMappingURL=main.js.map