Only activate stdin reader when stdin is a TTY
This commit is contained in:
parent
6b605b393d
commit
90579cea28
1 changed files with 13 additions and 9 deletions
10
stdin.js
10
stdin.js
|
@ -21,15 +21,19 @@ const guildID = "112760669178241024"
|
||||||
|
|
||||||
const extraContext = {}
|
const extraContext = {}
|
||||||
|
|
||||||
setImmediate(() => { // assign after since old extraContext data will get removed
|
if (process.stdin.isTTY) {
|
||||||
|
setImmediate(() => { // assign after since old extraContext data will get removed
|
||||||
if (!passthrough.repl) {
|
if (!passthrough.repl) {
|
||||||
const cli = repl.start({ prompt: "", eval: customEval, writer: s => s })
|
const cli = repl.start({ prompt: "", eval: customEval, writer: s => s })
|
||||||
Object.assign(cli.context, extraContext, passthrough)
|
Object.assign(cli.context, extraContext, passthrough)
|
||||||
passthrough.repl = cli
|
passthrough.repl = cli
|
||||||
} else Object.assign(passthrough.repl.context, extraContext)
|
} else {
|
||||||
|
Object.assign(passthrough.repl.context, extraContext)
|
||||||
|
}
|
||||||
// @ts-expect-error Says exit isn't assignable to a string
|
// @ts-expect-error Says exit isn't assignable to a string
|
||||||
sync.addTemporaryListener(passthrough.repl, "exit", () => process.exit())
|
sync.addTemporaryListener(passthrough.repl, "exit", () => process.exit())
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
|
|
Loading…
Reference in a new issue