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
19
lib/main.js
19
lib/main.js
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue