diff --git a/src/helpers/fs.ts b/src/helpers/fs.ts index fb14895..148a0c2 100644 --- a/src/helpers/fs.ts +++ b/src/helpers/fs.ts @@ -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; } } @@ -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; } } @@ -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; } } diff --git a/src/helpers/git.ts b/src/helpers/git.ts index 1b1bc03..5acf6ec 100644 --- a/src/helpers/git.ts +++ b/src/helpers/git.ts @@ -5,7 +5,7 @@ import { getExecOutput } from './github'; async function ensureRemoteExists(name: string, target: string): Promise { try { await exec('git', ['remote', 'add', name, target]); - } catch (e) { + } catch (e: any) { if ( ! e.message.match(/failed with exit code 3$/g)) { throw e; } diff --git a/src/index.ts b/src/index.ts index 994600b..bb3a2e4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -36,7 +36,7 @@ async function downloadSplitsh(): Promise { 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"); }