summaryrefslogtreecommitdiffstatshomepage
path: root/plugins
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2016-07-09 15:11:30 -0500
committer cracyc <cracyc@users.noreply.github.com>2016-07-09 15:11:30 -0500
commit72a499b54a7dd20fcab34d5b541e0f12ea23c8c5 (patch)
tree341ebfea161a2fd57e50dc008ccc80fb1627c419 /plugins
parentd7bf380fd9f521cf1fd0e68416b270f7ee071be3 (diff)
plugin path expansion (nw)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/boot.lua25
1 files changed, 22 insertions, 3 deletions
diff --git a/plugins/boot.lua b/plugins/boot.lua
index 7acf23ca19f..11ee6682bae 100644
--- a/plugins/boot.lua
+++ b/plugins/boot.lua
@@ -1,11 +1,30 @@
-- license:BSD-3-Clause
-- copyright-holders:Miodrag Milanovic
require('lfs')
-local dir = manager:options().entries.pluginspath:value()
-package.path = dir .. "/?.lua;" .. dir .. "/?/init.lua"
+
+local function env_replace(str)
+ local pathsep = package.config:sub(1,1)
+ local function dorep(val)
+ ret = os.getenv(val)
+ if ret then
+ return ret
+ end
+ return val
+ end
+
+ if pathsep == '\\' then
+ str = str:gsub("%%(%w+)%%", dorep)
+ else
+ str = str:gsub("%$(%w+)", dorep)
+ end
+ return str
+end
+local dir = env_replace(manager:options().entries.pluginspath:value())
+
+package.path = package.path .. ";" .. dir .. "/?.lua;" .. dir .. "/?/init.lua"
local json = require('json')
-function readAll(file)
+local function readAll(file)
local f = io.open(file, "rb")
local content = f:read("*all")
f:close()