From 4de3c01c49a400b98dfde1e375ba3e091f85641b Mon Sep 17 00:00:00 2001 From: Neil Shapiro Date: Wed, 18 May 2022 14:24:26 -0700 Subject: [PATCH] Add error message to catch if Deno.emit isn't a valid function (#19) --- src/functions.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/functions.ts b/src/functions.ts index 61cbf1a..d344713 100644 --- a/src/functions.ts +++ b/src/functions.ts @@ -84,11 +84,19 @@ const createFunctionFile = async ( isImportMapPresent = false; } - const result = await Deno.emit(fnFilePath, { - bundle: "module", - check: false, - importMapPath: isImportMapPresent ? importMapPath : undefined, - }); + let result; + try { + result = await Deno.emit(fnFilePath, { + bundle: "module", + check: false, + importMapPath: isImportMapPresent ? importMapPath : undefined, + }); + } catch (e) { + console.log( + "This is likely due to the newest versions of Deno no longer supporting Deno.emit(). Please downgrade your version of Deno to 1.21.3", + ); + throw new Error(e); + } // Write FN File and sourcemap file const fnFileRelative = path.join("functions", `${fnId}.js`);