Skip to content

Commit

Permalink
GPM.EFSW
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown-gd committed Jun 14, 2023
1 parent e7d0c81 commit e48fac4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lua/gpm/fs.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
local logger = gpm.Logger
local SERVER = SERVER
local util = util

-- https://github.com/Pika-Software/gm_asyncio
-- https://github.com/WilliamVenner/gm_async_write
if util.IsBinaryModuleInstalled( "asyncio" ) and pcall( require, "asyncio" ) then
logger:Info( "A third-party file system API 'asyncio' has been initialized." )
gpm.Logger:Info( "A third-party file system API 'asyncio' has been initialized." )
elseif SERVER and util.IsBinaryModuleInstalled( "async_write" ) and pcall( require, "async_write" ) then
logger:Info( "A third-party file system API 'async_write' has been initialized." )
gpm.Logger:Info( "A third-party file system API 'async_write' has been initialized." )
end

-- https://github.com/Pika-Software/gm_efsw
if util.IsBinaryModuleInstalled( "efsw" ) and pcall( require, "efsw" ) then
logger:Info( "gm_efsw is initialized, package auto-reload are available." )
gpm.Logger:Info( "gm_efsw is initialized, package auto-reload are available." )
end

-- Libraries
Expand All @@ -33,11 +32,11 @@ local ipairs = ipairs
local assert = assert
local type = type

-- TODO: Add drag-n-drop packages feature
-- TODO: Add support for single file packages (rewrite pattern)
if efsw ~= nil then
hook.Add( "FileWatchEvent", "GPM.AutoReload", function( actionID, _, filePath )
local importPath = string.match( filePath, ".*/lua/(packages/.*)/" )
hook.Add( "FileWatchEvent", "GPM.EFSW", function( action, _, filePath )
if action <= 0 then return end

local importPath = string.match( string.sub( filePath, 5 ), "packages/[^/]+" )
if not importPath then return end

local pkg = gpm.Packages[ importPath ]
Expand Down

0 comments on commit e48fac4

Please sign in to comment.