Improve readability

This commit is contained in:
Sergey Dolin 2023-07-12 00:28:42 +02:00
parent 93ae31f0a4
commit 1c500a4414
2 changed files with 39 additions and 25 deletions

31
dist/setup/index.js vendored
View file

@ -61338,7 +61338,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0; exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.addExecutablesToCache = exports.getGo = void 0;
const tc = __importStar(__nccwpck_require__(7784)); const tc = __importStar(__nccwpck_require__(7784));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
@ -61449,6 +61449,7 @@ function addExecutablesToCache(extPath, info, arch) {
return cachedDir; return cachedDir;
}); });
} }
exports.addExecutablesToCache = addExecutablesToCache;
function installGoVersion(info, auth, arch) { function installGoVersion(info, auth, arch) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`); core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
@ -61464,18 +61465,22 @@ function installGoVersion(info, auth, arch) {
extPath = path.join(extPath, 'go'); extPath = path.join(extPath, 'go');
} }
if (isWindows) { if (isWindows) {
const oldCacheDir = process.env['RUNNER_TOOL_CACHE'] || ''; const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'] || '';
const tempCacheDir = oldCacheDir.replace('C:', 'D:').replace('c:', 'd:'); const substitutedToolCacheRoot = defaultToolCacheRoot
process.env['RUNNER_TOOL_CACHE'] = tempCacheDir; .replace('C:', 'D:')
const cachedDir = yield addExecutablesToCache(extPath, info, arch); .replace('c:', 'd:');
const lnkDest = cachedDir; // make toolcache root to be on drive d:
const lnkSrc = lnkDest.replace(tempCacheDir, oldCacheDir); process.env['RUNNER_TOOL_CACHE'] = substitutedToolCacheRoot;
const lnkSrcDir = path.dirname(lnkSrc); const actualToolCacheDir = yield addExecutablesToCache(extPath, info, arch);
fs_1.default.mkdirSync(lnkSrcDir, { recursive: true }); // create a link from c: to d:
fs_1.default.symlinkSync(lnkDest, lnkSrc, 'junction'); const lnkSrc = actualToolCacheDir.replace(substitutedToolCacheRoot, defaultToolCacheRoot);
core.info(`Created link ${lnkSrc} => ${lnkDest}`); fs_1.default.mkdirSync(path.dirname(lnkSrc), { recursive: true });
process.env['RUNNER_TOOL_CACHE'] = oldCacheDir; fs_1.default.symlinkSync(actualToolCacheDir, lnkSrc, 'junction');
return cachedDir.replace(tempCacheDir, oldCacheDir); core.info(`Created link ${lnkSrc} => ${actualToolCacheDir}`);
// restore toolcache root to default drive c:
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
// make outer code to continue using toolcache as if it were installed on c:
return lnkSrc;
} }
return yield addExecutablesToCache(extPath, info, arch); return yield addExecutablesToCache(extPath, info, arch);
}); });

View file

@ -202,20 +202,29 @@ async function installGoVersion(
} }
if (isWindows) { if (isWindows) {
const oldCacheDir = process.env['RUNNER_TOOL_CACHE'] || ''; const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'] || '';
const tempCacheDir = oldCacheDir.replace('C:', 'D:').replace('c:', 'd:'); const substitutedToolCacheRoot = defaultToolCacheRoot
process.env['RUNNER_TOOL_CACHE'] = tempCacheDir; .replace('C:', 'D:')
.replace('c:', 'd:');
// make toolcache root to be on drive d:
process.env['RUNNER_TOOL_CACHE'] = substitutedToolCacheRoot;
const cachedDir = await addExecutablesToCache(extPath, info, arch); const actualToolCacheDir = await addExecutablesToCache(extPath, info, arch);
const lnkDest = cachedDir; // create a link from c: to d:
const lnkSrc = lnkDest.replace(tempCacheDir, oldCacheDir); const lnkSrc = actualToolCacheDir.replace(
const lnkSrcDir = path.dirname(lnkSrc); substitutedToolCacheRoot,
fs.mkdirSync(lnkSrcDir, {recursive: true}); defaultToolCacheRoot
fs.symlinkSync(lnkDest, lnkSrc, 'junction'); );
core.info(`Created link ${lnkSrc} => ${lnkDest}`); fs.mkdirSync(path.dirname(lnkSrc), {recursive: true});
process.env['RUNNER_TOOL_CACHE'] = oldCacheDir; fs.symlinkSync(actualToolCacheDir, lnkSrc, 'junction');
return cachedDir.replace(tempCacheDir, oldCacheDir); core.info(`Created link ${lnkSrc} => ${actualToolCacheDir}`);
// restore toolcache root to default drive c:
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
// make outer code to continue using toolcache as if it were installed on c:
return lnkSrc;
} }
return await addExecutablesToCache(extPath, info, arch); return await addExecutablesToCache(extPath, info, arch);