From 680724233d823c3119e2dca62c930f10d5494bce Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Fri, 15 Sep 2023 17:31:16 +0530 Subject: [PATCH] fmt: luau side loader --- src/loader.luau | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/loader.luau b/src/loader.luau index 98ed06a..ee46eff 100644 --- a/src/loader.luau +++ b/src/loader.luau @@ -2,40 +2,40 @@ local process = require("@lune/process") local jsonEncode = require("@lune/net").jsonEncode local possibleErrors = { - FILE_NOT_FOUND = "No file exist at the path", - NOT_A_MODULE = "Module must return at least one value" + FILE_NOT_FOUND = "No file exist at the path", + NOT_A_MODULE = "Module must return at least one value", } local _, resolvedMod = xpcall(function() -- [1] - Path to import - -- [2] - Whether module import or not + -- [2] - Whether module import or not local mod = require(process.args[1]) - if process.args[2] == "MODULE" and mod == nil then - error(possibleErrors.NOT_A_MODULE) - end + if process.args[2] == "MODULE" and mod == nil then + error(possibleErrors.NOT_A_MODULE) + end - return mod + return mod end, function(err) - -- We only need the msg, not trace - local errMsg = tostring(err):split("stack traceback:")[1] + -- We only need the msg, not trace + local errMsg = tostring(err):split("stack traceback:")[1] - for id, msg in possibleErrors do - if errMsg:match(msg) then - print(`[bun-loader-lune::ImportError::{id}] ` .. errMsg) - return - end - end + for id, msg in possibleErrors do + if errMsg:match(msg) then + print(`[bun-loader-lune::ImportError::{id}] ` .. errMsg) + return + end + end - print("-- [ImportError] --") - print(tostring(err)) + print("-- [ImportError] --") + print(tostring(err)) end) if process.args[2] == "MODULE" and typeof(resolvedMod) == "table" then - local modReprJson = jsonEncode(resolvedMod) + local modReprJson = jsonEncode(resolvedMod) - print("--start @generated JS compatible object--") - print(modReprJson) - print("--end @generated JS compatible object--") -end \ No newline at end of file + print("--start @generated JS compatible object--") + print(modReprJson) + print("--end @generated JS compatible object--") +end