File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 11import { readFile } from "fs/promises" ;
22import { SquareCloudBlobError } from "../structures/error" ;
33
4+ /**
5+ * Parses a path-like input into a Buffer
6+ * @param pathLike - File path string or Buffer
7+ * @returns Promise resolving to Buffer
8+ */
49export async function parsePathLike (
510 pathLike : string | Buffer ,
611) : Promise < Buffer > {
712 if ( typeof pathLike === "string" ) {
8- const fileBuffer = await readFile ( pathLike ) . catch ( ( ) => undefined ) ;
9-
10- if ( ! fileBuffer ) {
11- throw new SquareCloudBlobError ( "INVALID_FILE" , "File not found" ) ;
13+ try {
14+ const fileBuffer = await readFile ( pathLike ) ;
15+ return fileBuffer ;
16+ } catch {
17+ throw new SquareCloudBlobError ( "INVALID_FILE_PATH" , "File not found" ) ;
1218 }
13-
14- return fileBuffer ;
1519 }
1620
1721 return pathLike ;
You can’t perform that action at this time.
0 commit comments