3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-04-14 08:08:43 +00:00

Handle missing cargo installs gracefully

fixes #17
This commit is contained in:
Arpad Borsos 2021-05-30 10:55:21 +02:00
parent ebd95456c3
commit 31c41a926e
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298

View file

@ -86,6 +86,7 @@ export async function getCacheConfig(): Promise<CacheConfig> {
} }
export async function getCargoBins(): Promise<Set<string>> { export async function getCargoBins(): Promise<Set<string>> {
try {
const { installs }: { installs: { [key: string]: { bins: Array<string> } } } = JSON.parse( const { installs }: { installs: { [key: string]: { bins: Array<string> } } } = JSON.parse(
await fs.promises.readFile(path.join(paths.cargoHome, ".crates2.json"), "utf8"), await fs.promises.readFile(path.join(paths.cargoHome, ".crates2.json"), "utf8"),
); );
@ -96,6 +97,9 @@ export async function getCargoBins(): Promise<Set<string>> {
} }
} }
return bins; return bins;
} catch {
return new Set<string>();
}
} }
async function getRustKey(): Promise<string> { async function getRustKey(): Promise<string> {