Skip to content

Commit

Permalink
Move extension lazyloader inside the hs namespace. Closes #132
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsj committed Nov 14, 2014
1 parent e913514 commit b800184
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Hammerspoon/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ package.cpath=package.cpath..";"..modpath.."/?.so"

if autoload_extensions then
print("-- Lazily loading extensions")
_extensions = {}
hs._extensions = {}

-- Discover extensions in our .app bundle
local iter, dir_obj = require("hs.fs").dir(modpath.."/hs")
local extension = iter(dir_obj)
while extension do
if (extension ~= ".") and (extension ~= "..") then
_extensions[extension] = true
hs._extensions[extension] = true
end
extension = iter(dir_obj)
end

-- Inject a lazy extension loader into the main HS table
setmetatable(hs, {
__index = function(t, key)
if _extensions[key] ~= nil then
if hs._extensions[key] ~= nil then
print("-- Loading extension: "..key)
hs[key] = require("hs."..key)
return hs[key]
Expand Down

0 comments on commit b800184

Please sign in to comment.