From ffe052c4e3535ecbd992f384dede148d8feb216e Mon Sep 17 00:00:00 2001 From: Daniel Brady Date: Tue, 27 Mar 2018 23:36:34 -0400 Subject: [PATCH] Renaming hammerspoon dir to avoid package ambiguity --- README.md | 4 +++- {hs => hammerspoon}/application.lua | 0 {hs => hammerspoon}/canvas.lua | 2 +- {hs => hammerspoon}/chooser.lua | 0 {hs => hammerspoon}/fs.lua | 6 +++--- {hs => hammerspoon}/location.lua | 0 {hs => hammerspoon}/spotify.lua | 2 +- 7 files changed, 8 insertions(+), 6 deletions(-) rename {hs => hammerspoon}/application.lua (100%) rename {hs => hammerspoon}/canvas.lua (98%) rename {hs => hammerspoon}/chooser.lua (100%) rename {hs => hammerspoon}/fs.lua (86%) rename {hs => hammerspoon}/location.lua (100%) rename {hs => hammerspoon}/spotify.lua (75%) diff --git a/README.md b/README.md index be1b7e8..5d6bdf3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # lua-utils A collection of utilities I've built as-needed for progamming in Lua and working with [Hammerspoon](hammerspoon.org). -Utilities compatible with vanilla Lua 5.3 are at the top level, while those intended for working with and/or extending Hammerspoon core libraries are nested within the `hs` directory. +Utilities compatible with vanilla Lua 5.3 are at the top level, while those intended for working with and/or extending Hammerspoon core libraries are nested within the `hammerspoon` directory. + +**NOTE:** If using any `hammerspoon` utilities, be sure to add the `lua-utils/?.lua` and `lua-utils/hammerspoon/?.lua` patterns to your `package.path`: some of the Hammerspoon utilities rely on the vanilla Lua ones. diff --git a/hs/application.lua b/hammerspoon/application.lua similarity index 100% rename from hs/application.lua rename to hammerspoon/application.lua diff --git a/hs/canvas.lua b/hammerspoon/canvas.lua similarity index 98% rename from hs/canvas.lua rename to hammerspoon/canvas.lua index 69244f7..1eab3c3 100644 --- a/hs/canvas.lua +++ b/hammerspoon/canvas.lua @@ -4,7 +4,7 @@ module = module or require('hs.canvas') assert(type(module) == 'table', 'must provide a table to extend') require('hs.timer') -requrie('hs.fnutils') +require('hs.fnutils') ---- Rolling my own 'show and hide with fade-out': need to be able to cancel the animation. module.flashable = {} diff --git a/hs/chooser.lua b/hammerspoon/chooser.lua similarity index 100% rename from hs/chooser.lua rename to hammerspoon/chooser.lua diff --git a/hs/fs.lua b/hammerspoon/fs.lua similarity index 86% rename from hs/fs.lua rename to hammerspoon/fs.lua index 3e7e066..71855f1 100644 --- a/hs/fs.lua +++ b/hammerspoon/fs.lua @@ -25,8 +25,8 @@ function module.dirs(path) return directories end --- Load each file in a given directory, with any arguments given. -function module.loadAllFiles(rootDir, ...) +-- Load each file in a given directory with the given extension, with any arguments given. +function module.loadAllFiles(rootDir, ext, ...) -- Make sure our root ends with a directory marker. rootDir = rootDir:endsWith('/') and rootDir or rootDir..'/' @@ -34,7 +34,7 @@ function module.loadAllFiles(rootDir, ...) local _,scripts = hs.fs.dir(rootDir) repeat local filename = scripts:next() - if filename and filename ~= '.' and filename ~= '..' then + if filename and filename ~= '.' and filename ~= '..' and filename:endsWith(ext) then print('\t\tloading script: '..filename) -- Load the script, passing the given arguments as parameters to the Lua chunk. -- Using `assert(loadfile(...))` instead of `require` to be compatible with Spoons. diff --git a/hs/location.lua b/hammerspoon/location.lua similarity index 100% rename from hs/location.lua rename to hammerspoon/location.lua diff --git a/hs/spotify.lua b/hammerspoon/spotify.lua similarity index 75% rename from hs/spotify.lua rename to hammerspoon/spotify.lua index c22cb1f..b7f0016 100644 --- a/hs/spotify.lua +++ b/hammerspoon/spotify.lua @@ -2,7 +2,7 @@ local _,_,module = ... module = module or {} assert(type(module) == 'table', 'must provide a table to extend') -local tell = require('./application').tell +local tell = require('lua-utils/hammerspoon/application').tell module.tell = function(...) tell('Spotify', ...)