Skip to content

Commit

Permalink
Ensure installation directory exists before downloading binary
Browse files Browse the repository at this point in the history
- Updated the `download` method in `Binary` class to be asynchronous.
- Added a check to ensure the `installDir` directory exists before starting the download.
- If the directory does not exist, it is created with `fs.mkdir` using the `recursive` option.
  • Loading branch information
Pavel Ivanov committed Sep 3, 2024
1 parent 221dddf commit 96f4752
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion npm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ export class Binary {
return join(this.installDir, this.name);
}

download(url: URL): Promise<void> {
async download(url: URL): Promise<void> {
// Ensure the install directory exists
if (!await fileExists(this.installDir)) {
await fs.mkdir(this.installDir, { recursive: true });
}

return pipeline(
got.stream(url),
new stream.PassThrough(),
Expand Down

0 comments on commit 96f4752

Please sign in to comment.