mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
common/utils/tar.ts: reject with Error-type
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
55c284f8ef
commit
639bc1a510
@ -9,7 +9,7 @@ export interface ReadFileFromTarOpts {
|
|||||||
parseJson?: boolean;
|
parseJson?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function readFileFromTar<R = Buffer>({tarPath, filePath, parseJson}: ReadFileFromTarOpts): Promise<R> {
|
export function readFileFromTar<R = Buffer>({ tarPath, filePath, parseJson }: ReadFileFromTarOpts): Promise<R> {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const fileChunks: Buffer[] = [];
|
const fileChunks: Buffer[] = [];
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ export function readFileFromTar<R = Buffer>({tarPath, filePath, parseJson}: Read
|
|||||||
fileChunks.push(chunk);
|
fileChunks.push(chunk);
|
||||||
});
|
});
|
||||||
entry.once("error", err => {
|
entry.once("error", err => {
|
||||||
reject(`Reading ${entry.path} error: ${err}`);
|
reject(new Error(`reading file has failed ${entry.path}: ${err}`));
|
||||||
});
|
});
|
||||||
entry.once("end", () => {
|
entry.once("end", () => {
|
||||||
const data = Buffer.concat(fileChunks);
|
const data = Buffer.concat(fileChunks);
|
||||||
@ -32,7 +32,7 @@ export function readFileFromTar<R = Buffer>({tarPath, filePath, parseJson}: Read
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!fileChunks.length) {
|
if (!fileChunks.length) {
|
||||||
reject(null);
|
reject(new Error("Not found"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user