Skip to content

Commit

Permalink
✨ Add pre and post-process scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 13, 2020
1 parent 4127769 commit 3c84a05
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
19 changes: 19 additions & 0 deletions post-process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { readFile, writeFile, copyFile } from "fs-extra";
import { safeLoad } from "js-yaml";
import { join } from "path";

export const preProcess = async () => {
const config = safeLoad(await readFile(join("..", ".upptimerc.yml"), "utf8")) as {
"status-website"?: {
cname?: string;
};
};
if (config["status-website"]?.cname)
await writeFile(join(".", "__sapper__", "export", "CNAME"), config["status-website"]?.cname);
await copyFile(
join(".", "__sapper__", "export", "service-worker-index.html"),
join(".", "__sapper__", "export", "404.html")
);
};

preProcess();
22 changes: 22 additions & 0 deletions pre-process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { readFile, writeJson, ensureDir } from "fs-extra";
import { safeLoad } from "js-yaml";
import { join } from "path";

export const preProcess = async () => {
const i18n = safeLoad(await readFile(join(".", "i18n.yml"), "utf8")) as {
[index: string]: string;
};

const config = safeLoad(await readFile(join("..", ".upptimerc.yml"), "utf8")) as {
logoUrl?: string;
name?: string;
introTitle?: string;
introMessage?: string;
i18n?: { [index: string]: string };
};
config.i18n = { ...i18n, ...config.i18n };
await ensureDir(join(".", "src", "data"));
await writeJson(join(".", "src", "data", "config.json"), config);
};

preProcess();

0 comments on commit 3c84a05

Please sign in to comment.