|
|
@@ -25,22 +25,28 @@ for (const filename of options._ as string[]) {
|
|
|
(key, value) => key === "time" ? new Date(value) : value,
|
|
|
) as LogEntry;
|
|
|
if (options.files) {
|
|
|
- const matches = parsedLine.log.match(/>>>> file:(.+)/);
|
|
|
- if (matches) {
|
|
|
+ const startOfFileMatches = parsedLine.log.match(/>>>> file:(.+)/);
|
|
|
+ if (startOfFileMatches) {
|
|
|
imageReading = true;
|
|
|
- imageFilename = matches[1];
|
|
|
+ imageFilename = startOfFileMatches[1];
|
|
|
console.log("File found:", imageFilename);
|
|
|
continue;
|
|
|
}
|
|
|
- if (parsedLine.log.startsWith("<<<<")) {
|
|
|
+ const endOfFileMatches = parsedLine.log.match(/(.+)<<<</);
|
|
|
+ if (endOfFileMatches) {
|
|
|
imageReading = false;
|
|
|
const toFilename = `${path.dirname(filename)}/${path.basename(filename)}.${imageFilename}`;
|
|
|
console.log("Saving file to:", toFilename);
|
|
|
- Base64.fromBase64String(imageBase64Buffer).toFile(toFilename);
|
|
|
+ try {
|
|
|
+ imageBase64Buffer = imageBase64Buffer.concat(endOfFileMatches[1] ?? []);
|
|
|
+ Base64.fromBase64String(imageBase64Buffer).toFile(toFilename);
|
|
|
+ } catch {
|
|
|
+ console.log(imageBase64Buffer);
|
|
|
+ }
|
|
|
imageBase64Buffer = "";
|
|
|
continue;
|
|
|
}
|
|
|
- if (imageReading && !parsedLine.log.startsWith("cat")) {
|
|
|
+ if (imageReading && !parsedLine.log.startsWith("cat") && !parsedLine.log.startsWith("/etc/run.sh")) {
|
|
|
imageBase64Buffer = imageBase64Buffer.concat(parsedLine.log);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -49,6 +55,8 @@ for (const filename of options._ as string[]) {
|
|
|
encoder.encode(`${options.time ? parsedLine.time.toISOString() + " " : ""}${parsedLine.log}`),
|
|
|
);
|
|
|
}
|
|
|
+ } else if (imageReading) {
|
|
|
+ console.log(imageBase64Buffer);
|
|
|
}
|
|
|
}
|
|
|
file.close();
|