1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-27 13:47:41 +00:00

update shell with require

This commit is contained in:
kepler155c@gmail.com
2018-12-16 22:17:19 -05:00
parent 0aa0841b76
commit 7d64b0c6db
5 changed files with 143 additions and 13 deletions

View File

@@ -6,20 +6,21 @@ local Util = require('util')
local shell = _ENV.shell
local fs = _G.fs
local appPaths = Util.split(shell.path(), '(.-):')
local luaPaths = Util.split(_G.LUA_PATH, '(.-):')
local appPaths = Util.split(shell.path(), '(.-);')
local luaPaths = Util.split(_G.LUA_PATH, '(.-);')
local function addPath(t, e)
local function hasEntry()
local function addPath(t, path)
local function addEntry(e)
for _,v in ipairs(t) do
if v == e then
return true
end
end
end
if not hasEntry() then
table.insert(t, 1, e)
end
addEntry(string.format('/%s/?', path))
addEntry(string.format('/%s/?.lua', path))
addEntry(string.format('/%s/?/init.lua', path))
end
-- dependency graph
@@ -42,4 +43,4 @@ for name in pairs(Packages:installed()) do
end
shell.setPath(table.concat(appPaths, ':'))
_G.LUA_PATH = table.concat(luaPaths, ':')
_G.LUA_PATH = table.concat(luaPaths, ';')