mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
Do not throw exception in all cases
This commit is contained in:
parent
b179378e1e
commit
db0ba7321f
2 changed files with 13 additions and 6 deletions
|
@ -47,16 +47,23 @@ export const restoreCache = async (
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findDependencyFile = (packageManager: PackageManagerInfo) => {
|
export const findDependencyFile = (
|
||||||
|
packageManager: PackageManagerInfo,
|
||||||
|
throwException: boolean = true
|
||||||
|
) => {
|
||||||
let dependencyFile = packageManager.dependencyFilePattern;
|
let dependencyFile = packageManager.dependencyFilePattern;
|
||||||
const workspace = process.env.GITHUB_WORKSPACE!;
|
const workspace = process.env.GITHUB_WORKSPACE!;
|
||||||
const rootContent = fs.readdirSync(workspace);
|
const rootContent = fs.readdirSync(workspace);
|
||||||
|
|
||||||
const goSumFileExists = rootContent.includes(dependencyFile);
|
const goSumFileExists = rootContent.includes(dependencyFile);
|
||||||
if (!goSumFileExists) {
|
if (!goSumFileExists) {
|
||||||
throw new Error(
|
if (throwException) {
|
||||||
`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`
|
throw new Error(
|
||||||
);
|
`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.join(workspace, dependencyFile);
|
return path.join(workspace, dependencyFile);
|
||||||
|
|
|
@ -87,7 +87,7 @@ export async function isCacheEnabled() {
|
||||||
|
|
||||||
const packageManager = getCurrentPackageManager();
|
const packageManager = getCurrentPackageManager();
|
||||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||||
const cachePaths = findDependencyFile(packageManagerInfo);
|
const cachePaths = findDependencyFile(packageManagerInfo, false);
|
||||||
|
|
||||||
return cachePaths.length > 0;
|
return Boolean(cachePaths);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue