From 6e271e36b507c741c04ea3800a129075169d0613 Mon Sep 17 00:00:00 2001 From: Daniel Brady Date: Tue, 27 Mar 2018 23:19:27 -0400 Subject: [PATCH] Fix module loading to support 'require' --- hs/application.lua | 3 ++- hs/canvas.lua | 3 ++- hs/chooser.lua | 3 ++- hs/fs.lua | 5 +++-- hs/location.lua | 3 ++- hs/spotify.lua | 3 ++- math.lua | 3 ++- string.lua | 3 ++- table.lua | 3 ++- 9 files changed, 19 insertions(+), 10 deletions(-) diff --git a/hs/application.lua b/hs/application.lua index 83d9065..52d65c1 100644 --- a/hs/application.lua +++ b/hs/application.lua @@ -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') diff --git a/hs/canvas.lua b/hs/canvas.lua index 2b6b052..69244f7 100644 --- a/hs/canvas.lua +++ b/hs/canvas.lua @@ -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') diff --git a/hs/chooser.lua b/hs/chooser.lua index 261b70d..57b01f7 100644 --- a/hs/chooser.lua +++ b/hs/chooser.lua @@ -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 diff --git a/hs/fs.lua b/hs/fs.lua index e3fc4cf..3e7e066 100644 --- a/hs/fs.lua +++ b/hs/fs.lua @@ -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) diff --git a/hs/location.lua b/hs/location.lua index 1d1909a..4f680e3 100644 --- a/hs/location.lua +++ b/hs/location.lua @@ -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 diff --git a/hs/spotify.lua b/hs/spotify.lua index 97cb638..c22cb1f 100644 --- a/hs/spotify.lua +++ b/hs/spotify.lua @@ -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 diff --git a/math.lua b/math.lua index 9af8aa5..5bdbf34 100644 --- a/math.lua +++ b/math.lua @@ -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. diff --git a/string.lua b/string.lua index 96123cf..2a37997 100644 --- a/string.lua +++ b/string.lua @@ -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 --- diff --git a/table.lua b/table.lua index 57dd6fc..7dab3f5 100644 --- a/table.lua +++ b/table.lua @@ -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.