Skip to content

Commit

Permalink
Fix module loading to support 'require'
Browse files Browse the repository at this point in the history
  • Loading branch information
dabrady committed Mar 28, 2018
1 parent c01239b commit 6e271e3
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 10 deletions.
3 changes: 2 additions & 1 deletion hs/application.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Provide the ability to encapsulate the extensions into a different table.
local module = ... or require('hs.application')
local _,_,module = ...
module = module or require('hs.application')
assert(type(module) == 'table', 'must provide a table to extend')

require('hs.applescript')
Expand Down
3 changes: 2 additions & 1 deletion hs/canvas.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Provide the ability to encapsulate the extensions into a different table.
local module = ... or require('hs.canvas')
local _,_,module = ...
module = module or require('hs.canvas')
assert(type(module) == 'table', 'must provide a table to extend')

require('hs.timer')
Expand Down
3 changes: 2 additions & 1 deletion hs/chooser.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Provide the ability to encapsulate the extensions into a different table.
local module = ... or require('hs.chooser')
local _,_,module = ...
module = module or require('hs.chooser')
assert(type(module) == 'table', 'must provide a table to extend')

-- Takes a list of strings and creates a choice table formatted such that
Expand Down
5 changes: 3 additions & 2 deletions hs/fs.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
-- Provide the ability to encapsulate the extensions into a different table.
local module = ... or require('hs.fs')
local _,_,module = ...
module = module or require('hs.fs')
assert(type(module) == 'table', 'must provide a table to extend')

require '../string'
require('lua-utils/string')

-- Returns a list of directories in the given path.
function module.dirs(path)
Expand Down
3 changes: 2 additions & 1 deletion hs/location.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Provide the ability to encapsulate the extensions into a different table.
local module = ... or require('hs.location')
local _,_,module = ...
module = module or require('hs.location')
assert(type(module) == 'table', 'must provide a table to extend')
if not module.geocoder then module.geocoder = {} end

Expand Down
3 changes: 2 additions & 1 deletion hs/spotify.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local module = ... or {}
local _,_,module = ...
module = module or {}
assert(type(module) == 'table', 'must provide a table to extend')

local tell = require('./application').tell
Expand Down
3 changes: 2 additions & 1 deletion math.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Provide the ability to encapsulate the extensions into a different table.
local module = ... or math
local _,_,module = ...
module = module or math
assert(type(module) == 'table', 'must provide a table to extend')

-- Round the given number to the given number of decimal places.
Expand Down
3 changes: 2 additions & 1 deletion string.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Provide the ability to encapsulate the extensions into a different table.
local module = ... or string
local _,_,module = ...
module = module or string
assert(type(module) == 'table', 'must provide a table to extend')

--- Recipes for common string manipulations in Lua ---
Expand Down
3 changes: 2 additions & 1 deletion table.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Provide the ability to encapsulate the extensions into a different table.
local module = ... or table
local _,_,module = ...
module = module or table
assert(type(module) == 'table', 'must provide a table to extend')

-- Handy table formatting function. Supports arbitrary depth.
Expand Down

0 comments on commit 6e271e3

Please sign in to comment.