From 93dd1c5880ade0a824e2a62b1a04158fcb293ef1 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Wed, 27 Jan 2021 16:07:32 +0900 Subject: [PATCH] Avoid version corruption by passing loose option to semver.clean Signed-off-by: Sora Morimoto --- packages/tool-cache/src/tool-cache.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/tool-cache/src/tool-cache.ts b/packages/tool-cache/src/tool-cache.ts index 3e9ecab409..9bf3933179 100644 --- a/packages/tool-cache/src/tool-cache.ts +++ b/packages/tool-cache/src/tool-cache.ts @@ -381,7 +381,7 @@ export async function cacheDir( version: string, arch?: string ): Promise { - version = semver.clean(version) || version + version = semver.clean(version, {loose: true}) || version arch = arch || os.arch() core.debug(`Caching tool ${tool} ${version} ${arch}`) @@ -422,7 +422,7 @@ export async function cacheFile( version: string, arch?: string ): Promise { - version = semver.clean(version) || version + version = semver.clean(version, {loose: true}) || version arch = arch || os.arch() core.debug(`Caching tool ${tool} ${version} ${arch}`) @@ -478,7 +478,7 @@ export function find( // check for the explicit version in the cache let toolPath = '' if (versionSpec) { - versionSpec = semver.clean(versionSpec) || '' + versionSpec = semver.clean(versionSpec, {loose: true}) || '' const cachePath = path.join( _getCacheDirectory(), toolName, @@ -626,7 +626,7 @@ async function _createToolPath( const folderPath = path.join( _getCacheDirectory(), tool, - semver.clean(version) || version, + semver.clean(version, {loose: true}) || version, arch || '' ) core.debug(`destination ${folderPath}`) @@ -641,7 +641,7 @@ function _completeToolPath(tool: string, version: string, arch?: string): void { const folderPath = path.join( _getCacheDirectory(), tool, - semver.clean(version) || version, + semver.clean(version, {loose: true}) || version, arch || '' ) const markerPath = `${folderPath}.complete` @@ -650,7 +650,7 @@ function _completeToolPath(tool: string, version: string, arch?: string): void { } function _isExplicitVersion(versionSpec: string): boolean { - const c = semver.clean(versionSpec) || '' + const c = semver.clean(versionSpec, {loose: true}) || '' core.debug(`isExplicit: ${c}`) const valid = semver.valid(c) != null