fix: only move to bin directory when not cached
Some checks failed
Check Transpiled JavaScript / Check dist/ (push) Successful in 34s
Continuous Integration / GitHub Actions Test (push) Failing after 8s
Continuous Integration / TypeScript Tests (push) Successful in 49s

This commit is contained in:
Peter 2024-05-03 16:59:14 +02:00
parent 47b2964798
commit b025437574
Signed by: prskr
GPG key ID: F56BED6903BC5E37
5 changed files with 36 additions and 36 deletions

26
dist/index.js vendored
View file

@ -49389,10 +49389,9 @@ class Platform {
core.debug(`workDir: ${workDir}`);
return workDir;
}
async ensureBinDir(workDir) {
const binDir = external_path_default().join(workDir, 'bin');
async ensureBinDir() {
const binDir = external_path_default().join(this.getHomeDir(), Action.WorkDirName, 'bin');
await io.mkdirP(binDir);
core.addPath(binDir);
core.debug(`binDir: ${binDir}`);
return binDir;
}
@ -49444,8 +49443,6 @@ class HugoInstaller {
core.debug(`Operating System: ${this.platform.os}`);
core.debug(`Processor Architecture: ${this.platform.arch}`);
const hugoBinName = this.platform.binaryName(Hugo.CmdName);
const workDir = await this.platform.createWorkDir();
const binDir = await this.platform.ensureBinDir(workDir);
const tmpDir = external_node_os_namespaceObject.tmpdir();
try {
const cachedTool = tool_cache.find(Hugo.Name, release.tag_name, this.platform.arch);
@ -49471,13 +49468,16 @@ class HugoInstaller {
await tool_cache.extractTar(destPath, tmpDir);
}
await (0,io.rmRF)(destPath);
core.debug(`move binaries to binDir: ${binDir}`);
await (0,io.mv)(external_path_default().join(tmpDir, hugoBinName), binDir);
try {
await tool_cache.cacheFile(external_path_default().join(binDir, hugoBinName), hugoBinName, Hugo.Name, release.tag_name, this.platform.arch);
const cachedHugoPath = await tool_cache.cacheFile(external_path_default().join(tmpDir, hugoBinName), hugoBinName, Hugo.Name, release.tag_name, this.platform.arch);
core.addPath(cachedHugoPath);
}
catch (e) {
core.warning(`Failed to cache Hugo install: ${errorMsg(e)}`);
const binDir = await this.platform.ensureBinDir();
core.debug(`move binaries to binDir: ${binDir}`);
await (0,io.mv)(external_path_default().join(tmpDir, hugoBinName), binDir);
core.addPath(binDir);
}
}
}
@ -49560,8 +49560,6 @@ class DartSassInstaller {
const release = await this.releaseLookup.getRelease(DartSass.Org, DartSass.Repo, cmd.version, DartSassReleaseTransformer);
core.debug(`Operating System: ${this.platform.os}`);
core.debug(`Processor Architecture: ${this.platform.arch}`);
const workDir = await this.platform.createWorkDir();
const binDir = await this.platform.ensureBinDir(workDir);
const tmpDir = external_node_os_namespaceObject.tmpdir();
try {
const cachedDartSass = tool_cache.find(DartSass.Name, release.tag_name, this.platform.arch);
@ -49587,14 +49585,16 @@ class DartSassInstaller {
await tool_cache.extractTar(destPath, tmpDir);
}
await (0,io.rmRF)(destPath);
core.debug(`Move binaries to binDir: ${binDir}`);
await (0,io.mv)(external_path_default().join(tmpDir, 'dart-sass'), binDir);
core.debug(`Add 'dart-sass' directory to cache`);
try {
core.addPath(await tool_cache.cacheDir(external_path_default().join(binDir, 'dart-sass'), DartSass.Name, release.tag_name, this.platform.arch));
const cachedDartSass = await tool_cache.cacheDir(external_path_default().join(tmpDir, 'dart-sass'), DartSass.Name, release.tag_name, this.platform.arch);
core.addPath(cachedDartSass);
}
catch (e) {
core.warning(`Failed to cache dart-sass directory: ${errorMsg(e)}`);
const binDir = await this.platform.ensureBinDir();
core.debug(`Move binaries to binDir: ${binDir}`);
await (0,io.mv)(external_path_default().join(tmpDir, 'dart-sass'), binDir);
core.addPath(external_path_default().join(binDir, 'dart-sass'));
}
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -34,8 +34,6 @@ export class DartSassInstaller {
core.debug(`Operating System: ${this.platform.os}`)
core.debug(`Processor Architecture: ${this.platform.arch}`)
const workDir = await this.platform.createWorkDir()
const binDir = await this.platform.ensureBinDir(workDir)
const tmpDir = os.tmpdir()
try {
@ -73,22 +71,23 @@ export class DartSassInstaller {
await rmRF(destPath)
core.debug(`Move binaries to binDir: ${binDir}`)
await mv(path.join(tmpDir, 'dart-sass'), binDir)
core.debug(`Add 'dart-sass' directory to cache`)
try {
core.addPath(
await tc.cacheDir(
path.join(binDir, 'dart-sass'),
DartSass.Name,
release.tag_name,
this.platform.arch
)
const cachedDartSass = await tc.cacheDir(
path.join(tmpDir, 'dart-sass'),
DartSass.Name,
release.tag_name,
this.platform.arch
)
core.addPath(cachedDartSass)
} catch (e) {
core.warning(`Failed to cache dart-sass directory: ${errorMsg(e)}`)
const binDir = await this.platform.ensureBinDir()
core.debug(`Move binaries to binDir: ${binDir}`)
await mv(path.join(tmpDir, 'dart-sass'), binDir)
core.addPath(path.join(binDir, 'dart-sass'))
}
}

View file

@ -37,8 +37,6 @@ export class HugoInstaller {
core.debug(`Processor Architecture: ${this.platform.arch}`)
const hugoBinName = this.platform.binaryName(Hugo.CmdName)
const workDir = await this.platform.createWorkDir()
const binDir = await this.platform.ensureBinDir(workDir)
const tmpDir = os.tmpdir()
try {
@ -76,19 +74,23 @@ export class HugoInstaller {
await rmRF(destPath)
core.debug(`move binaries to binDir: ${binDir}`)
await mv(path.join(tmpDir, hugoBinName), binDir)
try {
await tc.cacheFile(
path.join(binDir, hugoBinName),
const cachedHugoPath = await tc.cacheFile(
path.join(tmpDir, hugoBinName),
hugoBinName,
Hugo.Name,
release.tag_name,
this.platform.arch
)
core.addPath(cachedHugoPath)
} catch (e) {
core.warning(`Failed to cache Hugo install: ${errorMsg(e)}`)
const binDir = await this.platform.ensureBinDir()
core.debug(`move binaries to binDir: ${binDir}`)
await mv(path.join(tmpDir, hugoBinName), binDir)
core.addPath(binDir)
}
}
}

View file

@ -48,10 +48,9 @@ export class Platform {
return workDir
}
async ensureBinDir(workDir: string): Promise<string> {
const binDir = path.join(workDir, 'bin')
async ensureBinDir(): Promise<string> {
const binDir = path.join(this.getHomeDir(), Action.WorkDirName, 'bin')
await io.mkdirP(binDir)
core.addPath(binDir)
core.debug(`binDir: ${binDir}`)
return binDir
}