Skip to content

Instantly share code, notes, and snippets.

@martinklepsch
Last active November 17, 2022 09:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinklepsch/49ed53cc18879fa1055b9bdd77471c95 to your computer and use it in GitHub Desktop.
Save martinklepsch/49ed53cc18879fa1055b9bdd77471c95 to your computer and use it in GitHub Desktop.
`deps.lua` is an all-in-one script containing your declarative list of dependencies and installing any missing ones.

deps.lua is an all-in-one script containing your declarative list of dependencies and installing any missing ones.

Kind of like Clojure's deps.edn except that the dependencies and code to download them are bundled in one package.

  • add link from file to gist so people can find back to here
  • add entries to .gitignore if available
  • ? if file ends in .fnl, download fennel.lua and compile to respective .lua file location

Usage in a fennel script

This will download moses.lua if it is missing (based on the list of files in deps.lua).

(require "deps")
(local M (require "moses"))
(print M)

📫 Subscribe to the gist for update notifications (unlikely 😂)

-- deps.lua - all-in-one declarative dependency handling
-- https://gist.github.com/martinklepsch/49ed53cc18879fa1055b9bdd77471c95
-- vim: sw=2 tw=2 et
deps = {
-- probably should not be using master branches here
["fennel.lua"] = "https://github.com/bakpakin/Fennel/blob/master/fennel.lua",
["moses.lua"] = "https://raw.githubusercontent.com/Yonaba/Moses/master/moses.lua"
}
for f, url in pairs(deps) do
local file_exists, _, code = os.execute("test -f " .. f)
if not file_exists then
local cmd = "curl -sL -o " .. f .. " " .. url
print(cmd)
os.execute(cmd)
print("You might want to add the downloaded file to your .gitignore")
else
-- print("exists")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment