1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-25 04:37:40 +00:00

reorganization

This commit is contained in:
kepler155c@gmail.com
2017-09-15 20:27:56 -04:00
parent 64c68f2662
commit 36fd5ca073
29 changed files with 2159 additions and 3500 deletions

View File

@@ -2,12 +2,12 @@ local git = require('git')
local gitfs = { }
function gitfs.mount(dir, user, repo, branch)
if not user or not repo then
error('gitfs syntax: user, repo, [branch]')
function gitfs.mount(dir, repo)
if not repo then
error('gitfs syntax: repo')
end
local list = git.list(user, repo, branch)
local list = git.list(repo)
for path, entry in pairs(list) do
if not fs.exists(fs.combine(dir, path)) then
local node = fs.mount(fs.combine(dir, path), 'urlfs', entry.url)

View File

@@ -6,8 +6,13 @@ local FILE_URL = 'https://raw.github.com/%s/%s/%s/%s'
local git = { }
function git.list(user, repo, branch)
branch = branch or 'master'
function git.list(repo)
local t = Util.split(repo, '(.-)/')
local user = t[1]
local repo = t[2]
local branch = t[3] or 'master'
local dataUrl = string.format(TREE_URL, user, repo, branch)
local contents = Util.download(dataUrl)

View File

@@ -379,8 +379,15 @@ function Util.download(url, filename)
end
function Util.loadUrl(url, env) -- loadfile equivalent
local c = Util.download(url)
return load(c, url, nil, env)
local s, m = pcall(function()
local c = Util.download(url)
return load(c, url, nil, env)
end)
if s then
return m
end
return s, m
end
function Util.runUrl(env, url, ...) -- os.run equivalent
@@ -390,7 +397,7 @@ function Util.runUrl(env, url, ...) -- os.run equivalent
fn, m = pcall(function() fn(unpack(args)) end)
end
if not fn and m and m ~= '' then
printError(m)
-- printError(m)
end
return fn, m
end