2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-01 19:23:24 +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
parent c96605e79c
commit 2e192be2e1
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD

View File

@ -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)