mirror of
https://github.com/kepler155c/opus
synced 2024-11-04 16:06:16 +00:00
42 lines
931 B
Lua
42 lines
931 B
Lua
_G.requireInjector(_ENV)
|
|
|
|
local Packages = require('packages')
|
|
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 function addPath(t, e)
|
|
local function hasEntry()
|
|
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
|
|
end
|
|
|
|
-- dependency graph
|
|
-- https://github.com/mpeterv/depgraph/blob/master/src/depgraph/init.lua
|
|
|
|
for name, package in pairs(Packages:installed()) do
|
|
if package.mount then
|
|
fs.mount(table.unpack(Util.matches(package.mount)))
|
|
end
|
|
|
|
addPath(appPaths, fs.combine('packages', name))
|
|
local apiPath = fs.combine(fs.combine('packages', name), 'apis')
|
|
if fs.exists(apiPath) then
|
|
addPath(luaPaths, apiPath)
|
|
end
|
|
end
|
|
|
|
shell.setPath(table.concat(appPaths, ':'))
|
|
_G.LUA_PATH = table.concat(luaPaths, ':')
|