2
2
镜像来自 https://github.com/Hilbis/Hilbish synced 2025-07-18 16:52:02 +00:00

refactor: setup autocd opt in a better way

with the previous commit allowing users to override
hilbish.runner.sh and it being ran by hilbish, the
code for the autocd opt can just override that
function and do the autocd functionality instead
of reimplementing a hybrid runner.

this means that if any other custom runner wants
autocd functionality they can have it with the sh runner
This commit is contained in:
TorchedSammy 2022-08-30 23:08:22 -04:00
父節點 c96605e79c
當前提交 2e192be2e1
簽署人: sammyette
GPG Key ID: 904FC49417B44DCD

查看文件

@ -1,13 +1,8 @@
local fs = require 'fs' local fs = require 'fs'
function cdHandle(inp) local oldShRunner = hilbish.runner.sh
local res = hilbish.runner.lua(inp) function hilbish.runner.sh(input)
local res = oldShRunner(input)
if not res.err then
return res
end
res = hilbish.runner.sh(inp)
if res.exit ~= 0 and hilbish.opts.autocd then if res.exit ~= 0 and hilbish.opts.autocd then
local ok, stat = pcall(fs.stat, res.input) local ok, stat = pcall(fs.stat, res.input)
@ -21,5 +16,3 @@ function cdHandle(inp)
return res return res
end end
hilbish.runner.setMode(cdHandle)