Skip to content

Commit

Permalink
fix new nodejs errors
Browse files Browse the repository at this point in the history
  • Loading branch information
absporl committed Oct 9, 2023
1 parent 1bc6669 commit 713446d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/helpers/fs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import * as fs from 'fs';

function isErrnoException(e: unknown): e is NodeJS.ErrnoException {
return ('code' in (e as any));
}

function dirExists(path: string): void {
try {
fs.mkdirSync(path);
} catch (err) {
if (err.code !== 'EEXIST') {
if (isErrnoException(err) && err.code !== 'EEXIST') {
throw err;
}
}
Expand All @@ -14,7 +18,7 @@ function removeDir(path: string) {
try {
fs.rmdirSync(path, { recursive: true });
} catch (err) {
if (err.code !== 'ENOENT') {
if (isErrnoException(err) && err.code !== 'ENOENT') {
throw err;
}
}
Expand All @@ -24,7 +28,7 @@ function removeFile(path: string) {
try {
fs.unlinkSync(path);
} catch (err) {
if (err.code !== 'ENOENT') {
if (isErrnoException(err) && err.code !== 'ENOENT') {
throw err;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function downloadSplitsh(): Promise<void> {

await exec(`wget -O ${downloadPath} ${url}`);
const output = await getExecOutput("sha256sum", [downloadPath]);
const hash = output.stdout.split(" ")[0];
const hash = output.split(" ")[0];
if (hash !== "2539301ce5e21d0ca44b689d0dd2c1b20d9f9e996c1fe6c462afb8af4e7141cc") {
throw new Error("Hash verification of downloaded splitsh failed");
}
Expand Down

0 comments on commit 713446d

Please sign in to comment.