This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 2385768cc feat: run `apisix init` in directory other than 
/usr/local/apisix (#7425)
2385768cc is described below

commit 2385768cc004ee6ac9f6d50167d2eb671669f3c0
Author: HaiYan <[email protected]>
AuthorDate: Sun Jul 17 20:50:35 2022 +0800

    feat: run `apisix init` in directory other than /usr/local/apisix (#7425)
---
 apisix/cli/apisix.lua | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/apisix/cli/apisix.lua b/apisix/cli/apisix.lua
index d284e2084..079691f51 100755
--- a/apisix/cli/apisix.lua
+++ b/apisix/cli/apisix.lua
@@ -18,14 +18,20 @@
 local pkg_cpath_org = package.cpath
 local pkg_path_org = package.path
 
+local _, find_pos_end = string.find(pkg_path_org, ";", -1, true)
+if not find_pos_end then
+    pkg_path_org = pkg_path_org .. ";"
+end
+
 local apisix_home = "/usr/local/apisix"
 local pkg_cpath = apisix_home .. "/deps/lib64/lua/5.1/?.so;"
                   .. apisix_home .. "/deps/lib/lua/5.1/?.so;"
-local pkg_path = apisix_home .. "/deps/share/lua/5.1/?.lua;"
+local pkg_path_deps = apisix_home .. "/deps/share/lua/5.1/?.lua;"
+local pkg_path_env = apisix_home .. "/?.lua;"
 
 -- modify the load path to load our dependencies
 package.cpath = pkg_cpath .. pkg_cpath_org
-package.path  = pkg_path .. pkg_path_org
+package.path  = pkg_path_deps .. pkg_path_org .. pkg_path_env
 
 -- pass path to construct the final result
 local env = require("apisix.cli.env")(apisix_home, pkg_cpath_org, pkg_path_org)

Reply via email to