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:
parent
6948892be9
commit
00676f1f60
5 changed files with 21 additions and 39 deletions
12
dist/main.js
vendored
12
dist/main.js
vendored
File diff suppressed because one or more lines are too long
6
dist/main.js.map
vendored
6
dist/main.js.map
vendored
File diff suppressed because one or more lines are too long
10
dist/post.js
vendored
10
dist/post.js
vendored
File diff suppressed because one or more lines are too long
6
dist/post.js.map
vendored
6
dist/post.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,5 @@
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
|
import * as os from "os";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
@ -43,30 +44,11 @@ export function getSshDirectory(): string {
|
||||||
* @returns home directory name
|
* @returns home directory name
|
||||||
*/
|
*/
|
||||||
function getHomeDirectory(): string {
|
function getHomeDirectory(): string {
|
||||||
const homeEnv = getHomeEnv();
|
const homedir = os.homedir();
|
||||||
const home = process.env[homeEnv];
|
if (homedir === "/github/home") {
|
||||||
if (home === undefined) {
|
|
||||||
throw Error(`${homeEnv} is not defined`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (home === "/github/home") {
|
|
||||||
// Docker container
|
// Docker container
|
||||||
return "/root";
|
return "/root";
|
||||||
}
|
}
|
||||||
|
|
||||||
return home;
|
return homedir;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get HOME environment name
|
|
||||||
* @returns HOME environment name
|
|
||||||
*/
|
|
||||||
function getHomeEnv(): string {
|
|
||||||
if (process.platform === "win32") {
|
|
||||||
// Windows
|
|
||||||
return "USERPROFILE";
|
|
||||||
}
|
|
||||||
|
|
||||||
// macOS / Linux
|
|
||||||
return "HOME";
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue