upkeep
fix git cwd override
targz support
Lua pebble can fetch and cache dependencies from the internet on demand.
Compatible with lua 5.4 or luajit on Linux.
require('pebble') -- init pebble
-- load a file from github using its pebble string
local fun = require('gh!luafun/luafun!fun.lua')
-- use the library as usual
print(fun.range(100):map(function(x) return x^2 end):reduce(fun.op.add, 0))
$ lua example.lua
pebble: fetching https://github.com/luafun/luafun.git
338350.0
install pebble.lua /usr/share/lua/common/
rm /usr/share/lua/common/pebble.lua
Pebble hooks into the require
function. When it detects you trying to require
some library using a pebble string, it checks to see if it is found inside
~/.cache/luapebble
. If it is there or if it is too old, it refetches the
dependency. Then it loads the library and returns it.
You can define a global PEBBLE
table to alter pebble behaviour. The default
values are:
PEBBLE = {
max_age_seconds = 60*60*24*7, -- Older than this gets refetched (week)
quiet = false, -- Dont print to stdout
verbose = false, -- Echo commands before executing
}