From 7dc6abde9dc5c6ac2a9d81105704ba1ea0a21dcb Mon Sep 17 00:00:00 2001 From: Andreas Albert Date: Thu, 19 May 2022 17:29:25 +0200 Subject: [PATCH 1/4] Fix installer cache path inconsistency --- dist/setup/index.js | 70 ++++++++++++++++++++++++++++++++++++------- src/installer/base.ts | 8 +++-- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 47ec13c2..7782bc47 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6948,9 +6948,11 @@ function ensureLocalInstaller(options) { } if (executablePath === "") { core.info(`Checking for cached ${tool}@${version}...`); - executablePath = tc.find(installerName, version, ...(options.arch ? [options.arch] : [])); - if (executablePath !== "") { - core.info(`Found ${installerName} cache at ${executablePath}!`); + let cacheDirectoryPath = tc.find(installerName, version, ...(options.arch ? [options.arch] : [])); + if (cacheDirectoryPath !== "") { + core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`); + executablePath = cacheDirectoryPath + "/" + installerName; + core.info(`executablePath is ${executablePath}`); } else { core.info(`Did not find ${installerName} ${version} in cache`); @@ -24281,7 +24283,31 @@ module.exports = YAMLException; /* 559 */, /* 560 */, /* 561 */, -/* 562 */, +/* 562 */ +/***/ (function(module) { + +/** Used to match a single whitespace character. */ +var reWhitespace = /\s/; + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ +function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; +} + +module.exports = trimmedEndIndex; + + +/***/ }), /* 563 */ /***/ (function(module) { @@ -32031,7 +32057,7 @@ module.exports.safeLoad = safeLoad; /* 771 */ /***/ (function(module) { -module.exports = {"_args":[["cheerio@1.0.0-rc.3","/Users/jrodriguez/devel/setup-miniconda"]],"_from":"cheerio@1.0.0-rc.3","_id":"cheerio@1.0.0-rc.3","_inBundle":false,"_integrity":"sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==","_location":"/cheerio","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"cheerio@1.0.0-rc.3","name":"cheerio","escapedName":"cheerio","rawSpec":"1.0.0-rc.3","saveSpec":null,"fetchSpec":"1.0.0-rc.3"},"_requiredBy":["/get-hrefs"],"_resolved":"https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz","_spec":"1.0.0-rc.3","_where":"/Users/jrodriguez/devel/setup-miniconda","author":{"name":"Matt Mueller","email":"mattmuelle@gmail.com","url":"mat.io"},"bugs":{"url":"https://github.com/cheeriojs/cheerio/issues"},"dependencies":{"css-select":"~1.2.0","dom-serializer":"~0.1.1","entities":"~1.1.1","htmlparser2":"^3.9.1","lodash":"^4.15.0","parse5":"^3.0.1"},"description":"Tiny, fast, and elegant implementation of core jQuery designed specifically for the server","devDependencies":{"benchmark":"^2.1.0","coveralls":"^2.11.9","expect.js":"~0.3.1","istanbul":"^0.4.3","jquery":"^3.0.0","jsdom":"^9.2.1","jshint":"^2.9.2","mocha":"^3.1.2","xyz":"~1.1.0"},"engines":{"node":">= 0.6"},"files":["index.js","lib"],"homepage":"https://github.com/cheeriojs/cheerio#readme","keywords":["htmlparser","jquery","selector","scraper","parser","html"],"license":"MIT","main":"./index.js","name":"cheerio","repository":{"type":"git","url":"git://github.com/cheeriojs/cheerio.git"},"scripts":{"test":"make test"},"version":"1.0.0-rc.3"}; +module.exports = {"_args":[["cheerio@1.0.0-rc.3","/work"]],"_from":"cheerio@1.0.0-rc.3","_id":"cheerio@1.0.0-rc.3","_inBundle":false,"_integrity":"sha512-0td5ijfUPuubwLUu0OBoe98gZj8C/AA+RW3v67GPlGOrvxWjZmBXiBCRU+I8VEiNyJzjth40POfHiz2RB3gImA==","_location":"/cheerio","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"cheerio@1.0.0-rc.3","name":"cheerio","escapedName":"cheerio","rawSpec":"1.0.0-rc.3","saveSpec":null,"fetchSpec":"1.0.0-rc.3"},"_requiredBy":["/get-hrefs"],"_resolved":"https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.3.tgz","_spec":"1.0.0-rc.3","_where":"/work","author":{"name":"Matt Mueller","email":"mattmuelle@gmail.com","url":"mat.io"},"bugs":{"url":"https://github.com/cheeriojs/cheerio/issues"},"dependencies":{"css-select":"~1.2.0","dom-serializer":"~0.1.1","entities":"~1.1.1","htmlparser2":"^3.9.1","lodash":"^4.15.0","parse5":"^3.0.1"},"description":"Tiny, fast, and elegant implementation of core jQuery designed specifically for the server","devDependencies":{"benchmark":"^2.1.0","coveralls":"^2.11.9","expect.js":"~0.3.1","istanbul":"^0.4.3","jquery":"^3.0.0","jsdom":"^9.2.1","jshint":"^2.9.2","mocha":"^3.1.2","xyz":"~1.1.0"},"engines":{"node":">= 0.6"},"files":["index.js","lib"],"homepage":"https://github.com/cheeriojs/cheerio#readme","keywords":["htmlparser","jquery","selector","scraper","parser","html"],"license":"MIT","main":"./index.js","name":"cheerio","repository":{"type":"git","url":"git://github.com/cheeriojs/cheerio.git"},"scripts":{"test":"make test"},"version":"1.0.0-rc.3"}; /***/ }), /* 772 */ @@ -32263,15 +32289,13 @@ module.exports = getWrapDetails; /* 790 */ /***/ (function(module, __unusedexports, __webpack_require__) { -var isObject = __webpack_require__(988), +var baseTrim = __webpack_require__(984), + isObject = __webpack_require__(988), isSymbol = __webpack_require__(186); /** Used as references for various `Number` constants. */ var NAN = 0 / 0; -/** Used to match leading and trailing whitespace. */ -var reTrim = /^\s+|\s+$/g; - /** Used to detect bad signed hexadecimal string values. */ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; @@ -32321,7 +32345,7 @@ function toNumber(value) { if (typeof value != 'string') { return value === 0 ? value : +value; } - value = value.replace(reTrim, ''); + value = baseTrim(value); var isBinary = reIsBinary.test(value); return (isBinary || reIsOctal.test(value)) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) @@ -38413,7 +38437,31 @@ module.exports = cacheHas; /***/ }), -/* 984 */, +/* 984 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +var trimmedEndIndex = __webpack_require__(562); + +/** Used to match leading whitespace. */ +var reTrimStart = /^\s+/; + +/** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ +function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; +} + +module.exports = baseTrim; + + +/***/ }), /* 985 */ /***/ (function(module, __unusedexports, __webpack_require__) { diff --git a/src/installer/base.ts b/src/installer/base.ts index f6eefedb..ea893162 100644 --- a/src/installer/base.ts +++ b/src/installer/base.ts @@ -46,13 +46,15 @@ export async function ensureLocalInstaller( if (executablePath === "") { core.info(`Checking for cached ${tool}@${version}...`); - executablePath = tc.find( + let cacheDirectoryPath = tc.find( installerName, version, ...(options.arch ? [options.arch] : []) ); - if (executablePath !== "") { - core.info(`Found ${installerName} cache at ${executablePath}!`); + if (cacheDirectoryPath !== "") { + core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`); + executablePath = cacheDirectoryPath + "/" + installerName; + core.info(`executablePath is ${executablePath}`); } else { core.info(`Did not find ${installerName} ${version} in cache`); } From b31939b83cd9beb3bc16b821dbcb3e9731ca7b0b Mon Sep 17 00:00:00 2001 From: AndreasAlbertQC <103571926+AndreasAlbertQC@users.noreply.github.com> Date: Mon, 23 May 2022 09:03:27 +0200 Subject: [PATCH 2/4] Update src/installer/base.ts Co-authored-by: Jonas Haag --- src/installer/base.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/installer/base.ts b/src/installer/base.ts index ea893162..209ae1c4 100644 --- a/src/installer/base.ts +++ b/src/installer/base.ts @@ -53,7 +53,7 @@ export async function ensureLocalInstaller( ); if (cacheDirectoryPath !== "") { core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`); - executablePath = cacheDirectoryPath + "/" + installerName; + executablePath = path.join([cacheDirectoryPath, installerName]); core.info(`executablePath is ${executablePath}`); } else { core.info(`Did not find ${installerName} ${version} in cache`); From b81279e0faf7b6a2f5bc068cdac452ea3bee9694 Mon Sep 17 00:00:00 2001 From: Andreas Albert Date: Mon, 23 May 2022 07:11:02 +0000 Subject: [PATCH 3/4] Clean up path.join syntax --- dist/setup/index.js | 62 ++++++------------------------------------- src/installer/base.ts | 2 +- 2 files changed, 9 insertions(+), 55 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 7782bc47..cf3227ab 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6951,7 +6951,7 @@ function ensureLocalInstaller(options) { let cacheDirectoryPath = tc.find(installerName, version, ...(options.arch ? [options.arch] : [])); if (cacheDirectoryPath !== "") { core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`); - executablePath = cacheDirectoryPath + "/" + installerName; + executablePath = path.join(cacheDirectoryPath, installerName); core.info(`executablePath is ${executablePath}`); } else { @@ -24283,31 +24283,7 @@ module.exports = YAMLException; /* 559 */, /* 560 */, /* 561 */, -/* 562 */ -/***/ (function(module) { - -/** Used to match a single whitespace character. */ -var reWhitespace = /\s/; - -/** - * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace - * character of `string`. - * - * @private - * @param {string} string The string to inspect. - * @returns {number} Returns the index of the last non-whitespace character. - */ -function trimmedEndIndex(string) { - var index = string.length; - - while (index-- && reWhitespace.test(string.charAt(index))) {} - return index; -} - -module.exports = trimmedEndIndex; - - -/***/ }), +/* 562 */, /* 563 */ /***/ (function(module) { @@ -32289,13 +32265,15 @@ module.exports = getWrapDetails; /* 790 */ /***/ (function(module, __unusedexports, __webpack_require__) { -var baseTrim = __webpack_require__(984), - isObject = __webpack_require__(988), +var isObject = __webpack_require__(988), isSymbol = __webpack_require__(186); /** Used as references for various `Number` constants. */ var NAN = 0 / 0; +/** Used to match leading and trailing whitespace. */ +var reTrim = /^\s+|\s+$/g; + /** Used to detect bad signed hexadecimal string values. */ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; @@ -32345,7 +32323,7 @@ function toNumber(value) { if (typeof value != 'string') { return value === 0 ? value : +value; } - value = baseTrim(value); + value = value.replace(reTrim, ''); var isBinary = reIsBinary.test(value); return (isBinary || reIsOctal.test(value)) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) @@ -38437,31 +38415,7 @@ module.exports = cacheHas; /***/ }), -/* 984 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -var trimmedEndIndex = __webpack_require__(562); - -/** Used to match leading whitespace. */ -var reTrimStart = /^\s+/; - -/** - * The base implementation of `_.trim`. - * - * @private - * @param {string} string The string to trim. - * @returns {string} Returns the trimmed string. - */ -function baseTrim(string) { - return string - ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') - : string; -} - -module.exports = baseTrim; - - -/***/ }), +/* 984 */, /* 985 */ /***/ (function(module, __unusedexports, __webpack_require__) { diff --git a/src/installer/base.ts b/src/installer/base.ts index 209ae1c4..ef87a81a 100644 --- a/src/installer/base.ts +++ b/src/installer/base.ts @@ -53,7 +53,7 @@ export async function ensureLocalInstaller( ); if (cacheDirectoryPath !== "") { core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`); - executablePath = path.join([cacheDirectoryPath, installerName]); + executablePath = path.join(cacheDirectoryPath, installerName); core.info(`executablePath is ${executablePath}`); } else { core.info(`Did not find ${installerName} ${version} in cache`); From 632ccd25464f78b9969af46418edda058778e8e6 Mon Sep 17 00:00:00 2001 From: Andreas Albert Date: Wed, 1 Jun 2022 12:21:44 +0000 Subject: [PATCH 4/4] Add comment to explain path manipulation --- dist/setup/index.js | 4 ++++ src/installer/base.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index cf3227ab..28116ff6 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6948,9 +6948,13 @@ function ensureLocalInstaller(options) { } if (executablePath === "") { core.info(`Checking for cached ${tool}@${version}...`); + // tc.find returns the name of the directory in which + // the cached file is located. let cacheDirectoryPath = tc.find(installerName, version, ...(options.arch ? [options.arch] : [])); if (cacheDirectoryPath !== "") { core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`); + // Append the basename of the cached file to the directory + // returned by tc.find executablePath = path.join(cacheDirectoryPath, installerName); core.info(`executablePath is ${executablePath}`); } diff --git a/src/installer/base.ts b/src/installer/base.ts index ef87a81a..b90b99af 100644 --- a/src/installer/base.ts +++ b/src/installer/base.ts @@ -46,6 +46,8 @@ export async function ensureLocalInstaller( if (executablePath === "") { core.info(`Checking for cached ${tool}@${version}...`); + // tc.find returns the name of the directory in which + // the cached file is located. let cacheDirectoryPath = tc.find( installerName, version, @@ -53,6 +55,9 @@ export async function ensureLocalInstaller( ); if (cacheDirectoryPath !== "") { core.info(`Found ${installerName} cache at ${cacheDirectoryPath}!`); + + // Append the basename of the cached file to the directory + // returned by tc.find executablePath = path.join(cacheDirectoryPath, installerName); core.info(`executablePath is ${executablePath}`); } else {