Skip to content

Commit

Permalink
Use assert and add extra check for filename
Browse files Browse the repository at this point in the history
  • Loading branch information
0x80 committed Nov 28, 2024
1 parent 76e165d commit 97efce9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/utils/pack.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import assert from "node:assert";
import { exec } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
Expand Down Expand Up @@ -49,11 +50,13 @@ export async function pack(srcDir: string, dstDir: string) {
});

const lastLine = stdout.trim().split("\n").at(-1);
if (!lastLine) {
throw new Error(`Failed to parse last line from stdout: ${stdout.trim()}`);
}

assert(lastLine, `Failed to parse last line from stdout: ${stdout.trim()}`);

const fileName = path.basename(lastLine);

assert(fileName, `Failed to parse file name from: ${lastLine}`);

const filePath = path.join(dstDir, fileName);

if (!fs.existsSync(filePath)) {
Expand Down

0 comments on commit 97efce9

Please sign in to comment.