Fix some problems with user's directory

To accommodate the Window's platform prefer the USERPROFILE to HOME
to set user's dir.

Fix error, user's dir was not added to the package.path.
This commit is contained in:
Francesco Abbate 2020-12-02 16:43:35 +01:00
parent a337f893d9
commit 277186491a
1 changed files with 8 additions and 5 deletions

View File

@ -127,11 +127,14 @@ int main(int argc, char **argv) {
" DATADIR = EXEDIR .. '/data'\n"
" USERDIR = EXEDIR .. '/user'\n"
#else
" local prefix = EXEDIR:match(\"^(.+)[/\\\\]bin$\")\n"
" DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data')\n"
" USERDIR = os.getenv(\"HOME\") .. '/.config/lite-xl'\n"
" package.path = package.path .. ';' .. DATADIR .. '/?.lua'\n"
" package.path = package.path .. ';' .. DATADIR .. '/?/init.lua'\n"
" do\n"
" local prefix = EXEDIR:match(\"^(.+)[/\\\\]bin$\")\n"
" DATADIR = prefix and (prefix .. '/share/lite-xl') or (EXEDIR .. '/data')\n"
" local home = os.getenv('USERPROFILE') or os.getenv('HOME')\n"
" USERDIR = home and home .. '/.config/lite-xl' or (EXEDIR .. '/user')\n"
" end\n"
" package.path = package.path .. ';' .. USERDIR .. '/?.lua'\n"
" package.path = package.path .. ';' .. USERDIR .. '/?/init.lua'\n"
#endif
" package.path = DATADIR .. '/?.lua;' .. package.path\n"
" package.path = DATADIR .. '/?/init.lua;' .. package.path\n"