From 0b03f15a89901ffd1ab086359f0999701a16d743 Mon Sep 17 00:00:00 2001 From: PrikolMen Date: Thu, 25 May 2023 13:43:09 +0400 Subject: [PATCH] Few fixes/changes --- lua/gpm/package.lua | 4 ++-- lua/gpm/sources/gma.lua | 10 +++++----- lua/gpm/sources/lua.lua | 14 +++++++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lua/gpm/package.lua b/lua/gpm/package.lua index b760584d..f01167ec 100644 --- a/lua/gpm/package.lua +++ b/lua/gpm/package.lua @@ -296,9 +296,9 @@ Initialize = promise.Async( function( metadata, func, files ) if type( func ) ~= "function" then local currentFile = utils.GetCurrentFile() if currentFile then - local folder = string.GetPathFromFilename( paths.Localize( currentFile ) ) + local folder = paths.Localize( string.GetPathFromFilename( currentFile ) ) if folder then - local filePath = paths.Fix( folder .. fileName ) + local filePath = folder .. fileName if fs.IsFile( filePath, luaRealm ) then func = gpm.CompileLua( filePath ):Await() end diff --git a/lua/gpm/sources/gma.lua b/lua/gpm/sources/gma.lua index 44ff9673..3107ce4e 100644 --- a/lua/gpm/sources/gma.lua +++ b/lua/gpm/sources/gma.lua @@ -53,17 +53,17 @@ Import = promise.Async( function( metadata ) importPaths[ #importPaths + 1 ] = importPath end - local results = {} + local packages = {} for _, importPath in ipairs( importPaths ) do - results[ #results + 1 ] = gpm.SourceImport( "lua", importPath ) + packages[ #packages + 1 ] = gpm.SourceImport( "lua", importPath ):Await() end - local count = #results + local count = #packages if count > 0 then if count == 1 then - return results[ 1 ] + return packages[ 1 ] end - return results + return packages end end ) \ No newline at end of file diff --git a/lua/gpm/sources/lua.lua b/lua/gpm/sources/lua.lua index f99169a5..dcb3218f 100644 --- a/lua/gpm/sources/lua.lua +++ b/lua/gpm/sources/lua.lua @@ -50,7 +50,7 @@ GetMetadata = promise.Async( function( importPath ) metadata = package.GetMetadata( result ) end - -- For single file + -- Single file if not metadata then metadata = { ["autorun"] = true @@ -73,7 +73,9 @@ GetMetadata = promise.Async( function( importPath ) -- Shared init local main = metadata.main - if type( main ) ~= "string" then + if type( main ) == "string" then + main = paths.Fix( main ) + else main = "init.lua" end @@ -89,14 +91,16 @@ GetMetadata = promise.Async( function( importPath ) end if fs.IsFile( main, luaRealm ) then - metadata.main = paths.Fix( main ) + metadata.main = main else metadata.main = nil end -- Client init local cl_main = metadata.cl_main - if type( cl_main ) ~= "string" then + if type( cl_main ) == "string" then + cl_main = paths.Fix( cl_main ) + else cl_main = "cl_init.lua" end @@ -108,7 +112,7 @@ GetMetadata = promise.Async( function( importPath ) end if fs.IsFile( cl_main, luaRealm ) then - metadata.cl_main = paths.Fix( cl_main ) + metadata.cl_main = cl_main else metadata.cl_main = nil end