mirror of https://github.com/Hilbis/Hilbish
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 runnerpull/207/head
parent
c96605e79c
commit
2e192be2e1
|
@ -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)
|
|
||||||
|
|
Loading…
Reference in New Issue