Only replace tilde in certain scenarios

This commit is contained in:
Konrad Pabjan 2020-07-29 18:17:27 +02:00
parent 0bc4c5f195
commit 23faf7dc6f
2 changed files with 14 additions and 5 deletions

9
dist/index.js vendored
View file

@ -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) {

View file

@ -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<void> {
@ -9,8 +9,12 @@ async function run(): Promise<void> {
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()