mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-19 22:52:10 +10:00
refactor
This commit is contained in:
parent
74af40b44a
commit
91f978d590
2 changed files with 25 additions and 22 deletions
23
lib/index.js
23
lib/index.js
|
@ -446,16 +446,7 @@ function main() {
|
|||
mode: 0o700,
|
||||
});
|
||||
// files to be created
|
||||
const files = [
|
||||
{
|
||||
name: "config",
|
||||
contents: insertLf(config, true, true),
|
||||
options: {
|
||||
mode: 0o644,
|
||||
flag: "a",
|
||||
},
|
||||
},
|
||||
];
|
||||
const files = [];
|
||||
if (shouldCreateKeyFile(path_1.default.join(dirName, name), ifKeyExists)) {
|
||||
files.push({
|
||||
name: name,
|
||||
|
@ -466,7 +457,7 @@ function main() {
|
|||
},
|
||||
});
|
||||
}
|
||||
if (!noKnownHosts) {
|
||||
if (knownHosts !== "") {
|
||||
files.push({
|
||||
name: "known_hosts",
|
||||
contents: insertLf(knownHosts, true, true),
|
||||
|
@ -476,6 +467,16 @@ function main() {
|
|||
},
|
||||
});
|
||||
}
|
||||
if (config !== "") {
|
||||
files.push({
|
||||
name: "config",
|
||||
contents: insertLf(config, true, true),
|
||||
options: {
|
||||
mode: 0o644,
|
||||
flag: "a",
|
||||
},
|
||||
});
|
||||
}
|
||||
// create files
|
||||
for (const file of files) {
|
||||
const fileName = path_1.default.join(dirName, file.name);
|
||||
|
|
24
src/main.ts
24
src/main.ts
|
@ -38,16 +38,7 @@ function main(): void
|
|||
});
|
||||
|
||||
// files to be created
|
||||
const files: FileInfo[] = [
|
||||
{
|
||||
name: "config",
|
||||
contents: insertLf(config, true, true),
|
||||
options: {
|
||||
mode: 0o644,
|
||||
flag: "a",
|
||||
},
|
||||
},
|
||||
];
|
||||
const files: FileInfo[] = [];
|
||||
if(shouldCreateKeyFile(path.join(dirName, name), ifKeyExists))
|
||||
{
|
||||
files.push({
|
||||
|
@ -59,7 +50,7 @@ function main(): void
|
|||
},
|
||||
});
|
||||
}
|
||||
if(!noKnownHosts)
|
||||
if(knownHosts !== "")
|
||||
{
|
||||
files.push({
|
||||
name: "known_hosts",
|
||||
|
@ -70,6 +61,17 @@ function main(): void
|
|||
},
|
||||
});
|
||||
}
|
||||
if(config !== "")
|
||||
{
|
||||
files.push({
|
||||
name: "config",
|
||||
contents: insertLf(config, true, true),
|
||||
options: {
|
||||
mode: 0o644,
|
||||
flag: "a",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// create files
|
||||
for(const file of files)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue