From bc5c781c707062712e1676d61cfd17c04b23c615 Mon Sep 17 00:00:00 2001 From: Sean Meininger Date: Fri, 7 Oct 2022 17:37:26 -0700 Subject: [PATCH] added check for sentinel.hcl --- src/main.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.ts b/src/main.ts index 8dde3ed..f3a1999 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,16 @@ const fs = require("fs"); import {generateHereDoc, functionUrls} from "./configHeredoc"; import {ripGrep} from "./ripGrep"; +// Check for the presence of sentinel.hcl, or else one gets created +const ensureFileExists = async (filename: string) => { + try { + return await fs.lstatSync(filename).isFile(); + } catch(e) { + console.log(`${filename} not present. Are you running this in the right directory?`); + console.log(e); + } +} + const checkForCommonFunctions = async (functionsArray: Array) => { // iterate over all common functions by name for (const i of functionsArray) { @@ -21,6 +31,8 @@ const checkForCommonFunctions = async (functionsArray: Array) => { const main = async () => { console.log('Starting checks'); + //make sure you're in the right directory to avoid nonsense + ensureFileExists('sentinel.hcl'); checkForCommonFunctions(Object.keys(functionUrls)); }