fix: Dont error on missing index dir.

This commit is contained in:
Miles Johnson 2023-04-17 16:29:55 -07:00
parent aaa9e56585
commit 8e43d3720d
2 changed files with 12 additions and 10 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@moonrepo/setup-rust",
"version": "0.3.5",
"version": "0.3.6",
"description": "A GitHub action for setting up Rust and Cargo.",
"main": "dist/index.js",
"scripts": {

View file

@ -132,17 +132,19 @@ export async function cleanCargoRegistry() {
// .cargo/registry/index - Delete .cache directories
const indexDir = path.join(registryDir, 'index');
for (const index of fs.readdirSync(indexDir)) {
if (fs.existsSync(path.join(indexDir, index, '.git'))) {
const dir = path.join(indexDir, index, '.cache');
if (fs.existsSync(indexDir)) {
for (const index of fs.readdirSync(indexDir)) {
if (fs.existsSync(path.join(indexDir, index, '.git'))) {
const dir = path.join(indexDir, index, '.cache');
core.debug(`Deleting ${dir}`);
core.debug(`Deleting ${dir}`);
try {
// eslint-disable-next-line no-await-in-loop
await io.rmRF(dir);
} catch (error: unknown) {
core.warning(`Failed to delete ${dir}: ${error}`);
try {
// eslint-disable-next-line no-await-in-loop
await io.rmRF(dir);
} catch (error: unknown) {
core.warning(`Failed to delete ${dir}: ${error}`);
}
}
}
}