From 23faf7dc6f9e3a3a039ab16be6d87aeb75bb1d4a Mon Sep 17 00:00:00 2001 From: Konrad Pabjan Date: Wed, 29 Jul 2020 18:17:27 +0200 Subject: [PATCH] Only replace tilde in certain scenarios --- dist/index.js | 9 +++++++-- src/download-artifact.ts | 10 +++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index d129c68..212c3cc 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6642,8 +6642,13 @@ function run() { try { const name = core.getInput(constants_1.Inputs.Name, { required: false }); const path = core.getInput(constants_1.Inputs.Path, { required: false }); - // resolve tilde expansion - const resolvedPath = path_1.resolve(path.replace('~', os.homedir)); + let resolvedPath; + if (path === '~' || path.startsWith(`~${path_1.sep}`)) { + resolvedPath = path_1.resolve(path.replace('~', os.homedir())); + } + else { + resolvedPath = path_1.resolve(path); + } core.debug(`Resolved path is ${resolvedPath}`); const artifactClient = artifact.create(); if (!name) { diff --git a/src/download-artifact.ts b/src/download-artifact.ts index 765e148..5621fec 100644 --- a/src/download-artifact.ts +++ b/src/download-artifact.ts @@ -1,7 +1,7 @@ import * as core from '@actions/core' import * as artifact from '@actions/artifact' import * as os from 'os' -import {resolve} from 'path' +import {resolve, sep} from 'path' import {Inputs, Outputs} from './constants' async function run(): Promise { @@ -9,8 +9,12 @@ async function run(): Promise { const name = core.getInput(Inputs.Name, {required: false}) const path = core.getInput(Inputs.Path, {required: false}) - // resolve tilde expansion - const resolvedPath = resolve(path.replace('~', os.homedir)) + let resolvedPath + if (path === '~' || path.startsWith(`~${sep}`)) { + resolvedPath = resolve(path.replace('~', os.homedir())) + } else { + resolvedPath = resolve(path) + } core.debug(`Resolved path is ${resolvedPath}`) const artifactClient = artifact.create()