From e372b56bb76d953df6bfdcab6bbe5cc951759065 Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Fri, 22 Nov 2019 10:26:02 +0900 Subject: [PATCH] feat: Add baseLocation --- lib/index.js | 14 +++++++++++++- src/installer.ts | 12 +++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index d440da4..19354c7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5163,7 +5163,19 @@ function installer(version) { console.log(`Operating System: ${osName}`); const hugoURL = get_url_1.default(osName, extended, version); core.debug(`hugoURL: ${hugoURL}`); - const hugoPath = path.join(`${process.env.HOME}`, 'bin'); + let baseLocation; + if (process.platform === 'win32') { + baseLocation = process.env['USERPROFILE'] || 'C:\\'; + } + else { + if (process.platform === 'darwin') { + baseLocation = '/Users'; + } + else { + baseLocation = '/home'; + } + } + const hugoPath = path.join(baseLocation, 'actions', 'bin'); yield io.mkdirP(hugoPath); core.addPath(hugoPath); const hugoAssets = yield tc.downloadTool(hugoURL); diff --git a/src/installer.ts b/src/installer.ts index 49bc59f..b9ba6ec 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -16,7 +16,17 @@ export default async function installer(version: string) { const hugoURL: string = getURL(osName, extended, version); core.debug(`hugoURL: ${hugoURL}`); - const hugoPath: string = path.join(`${process.env.HOME}`, 'bin'); + let baseLocation: string; + if (process.platform === 'win32') { + baseLocation = process.env['USERPROFILE'] || 'C:\\'; + } else { + if (process.platform === 'darwin') { + baseLocation = '/Users'; + } else { + baseLocation = '/home'; + } + } + const hugoPath: string = path.join(baseLocation, 'actions', 'bin'); await io.mkdirP(hugoPath); core.addPath(hugoPath);