From 87342a796587acb84646e49b68136c7820b465e8 Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Wed, 28 Oct 2020 16:43:12 +0530 Subject: [PATCH] :recycle: Use 2 dir up config --- post-process.ts | 16 +++------------- pre-process.ts | 10 +--------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/post-process.ts b/post-process.ts index c7d6198..352967e 100644 --- a/post-process.ts +++ b/post-process.ts @@ -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}`, { @@ -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( @@ -39,4 +29,4 @@ export const preProcess = async () => { ); }; -preProcess(); +postProcess(); diff --git a/pre-process.ts b/pre-process.ts index 647df30..e221f2c 100644 --- a/pre-process.ts +++ b/pre-process.ts @@ -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"));