diff --git a/package.json b/package.json index 6e21709..f572974 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/cargo.ts b/src/cargo.ts index 4c4230a..27406a8 100644 --- a/src/cargo.ts +++ b/src/cargo.ts @@ -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}`); + } } } }