Skip to content

Commit

Permalink
♻️ Use 2 dir up config
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Oct 28, 2020
1 parent a7a94d0 commit 87342a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
16 changes: 3 additions & 13 deletions post-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { safeLoad } from "js-yaml";
import { join } from "path";
import { execSync } from "child_process";

export const preProcess = async () => {
export const postProcess = async () => {
let config: {
"status-website"?: {
cname?: string;
baseUrl?: string;
};
} = safeLoad(await readFile(join(".", ".upptimerc.yml"), "utf8")) as any;
} = safeLoad(await readFile(join("..", "..", ".upptimerc.yml"), "utf8")) as any;
const baseUrl = (config["status-website"] || {}).baseUrl || "/";

execSync(`sapper export --legacy --basepath ${baseUrl}`, {
Expand All @@ -21,16 +21,6 @@ export const preProcess = async () => {
await remove(join(".", "__sapper__", "export", baseUrl));
}

try {
const file = await readFile(join("..", "..", ".upptimerc.yml"), "utf8");
if (file) {
config = safeLoad(file) as any;
console.log("Using root config instead", config);
}
} catch (error) {
console.log("Root config not found 2 dirs up");
}

if (config["status-website"] && config["status-website"].cname)
await writeFile(join(".", "__sapper__", "export", "CNAME"), config["status-website"].cname);
await copyFile(
Expand All @@ -39,4 +29,4 @@ export const preProcess = async () => {
);
};

preProcess();
postProcess();
10 changes: 1 addition & 9 deletions pre-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ export const preProcess = async () => {
introTitle?: string;
introMessage?: string;
i18n?: { [index: string]: string };
} = safeLoad(await readFile(join(".", ".upptimerc.yml"), "utf8")) as any;

try {
const file = await readFile(join("..", "..", ".upptimerc.yml"), "utf8");
if (file) {
config = safeLoad(file) as any;
console.log("Using root config instead");
}
} catch (error) {}
} = safeLoad(await readFile(join("..", "..", ".upptimerc.yml"), "utf8")) as any;

config.i18n = { ...i18n, ...config.i18n };
await ensureDir(join(".", "src", "data"));
Expand Down

0 comments on commit 87342a7

Please sign in to comment.