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

use os.homedir() in order to get home directory (#253)

This commit is contained in:
shimataro 2023-10-11 05:04:21 +09:00 committed by GitHub
parent 6948892be9
commit 00676f1f60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 39 deletions

12
dist/main.js vendored

File diff suppressed because one or more lines are too long

6
dist/main.js.map vendored

File diff suppressed because one or more lines are too long

10
dist/post.js vendored

File diff suppressed because one or more lines are too long

6
dist/post.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,5 @@
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as core from "@actions/core";
@ -43,30 +44,11 @@ export function getSshDirectory(): string {
* @returns home directory name
*/
function getHomeDirectory(): string {
const homeEnv = getHomeEnv();
const home = process.env[homeEnv];
if (home === undefined) {
throw Error(`${homeEnv} is not defined`);
}
if (home === "/github/home") {
const homedir = os.homedir();
if (homedir === "/github/home") {
// Docker container
return "/root";
}
return home;
}
/**
* get HOME environment name
* @returns HOME environment name
*/
function getHomeEnv(): string {
if (process.platform === "win32") {
// Windows
return "USERPROFILE";
}
// macOS / Linux
return "HOME";
return homedir;
}