Skip to content

Commit 20ce15b

Browse files
committed
Saving output
1 parent e33a3e0 commit 20ce15b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/commands/FetchPreview.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import TempFileService from "../TempFileService";
44
import * as cheerio from "cheerio";
55
import { IEvent } from "../IEvent";
66
import { JSDOM } from "jsdom";
7+
import { writeFile } from "fs/promises";
78

89
export default class FetchPreview extends Command {
910

@@ -39,6 +40,14 @@ export default class FetchPreview extends Command {
3940

4041
if (!url) {
4142
console.log(`Failed to load url`);
43+
44+
const htmlFile = await TempFileService.getTempFile(".html");
45+
await writeFile(htmlFile.path, content, "utf8");
46+
47+
await this.upload({ url: output , filePath: htmlFile.path});
48+
49+
throw new Error(`Failed to load url , saved content at ${output.split("?")[0]}`);
50+
4251
}
4352

4453
const file = await TempFileService.getTempFile(".jpg");

0 commit comments

Comments
 (0)