noninteractive 0.3.21 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/noninteractive.js +9 -5
- package/package.json +1 -1
package/bin/noninteractive.js
CHANGED
|
@@ -364,7 +364,7 @@ var init_daemon = __esm(() => {
|
|
|
364
364
|
var require_package = __commonJS((exports, module) => {
|
|
365
365
|
module.exports = {
|
|
366
366
|
name: "noninteractive",
|
|
367
|
-
version: "0.3.
|
|
367
|
+
version: "0.3.22",
|
|
368
368
|
type: "module",
|
|
369
369
|
bin: {
|
|
370
370
|
noninteractive: "./bin/noninteractive.js"
|
|
@@ -474,13 +474,15 @@ flags:
|
|
|
474
474
|
|
|
475
475
|
the session name is auto-derived from the tool (e.g. "workos" \u2192 session "workos").
|
|
476
476
|
|
|
477
|
-
text is sent
|
|
477
|
+
text is sent raw \u2014 no auto-appended enter. escape sequences are parsed:
|
|
478
|
+
\\r = Enter, \\n = newline, \\t = tab, \\x1b = escape (for arrow keys)
|
|
478
479
|
|
|
479
480
|
example workflow:
|
|
480
481
|
npx noninteractive workos # starts "npx workos", session = "workos"
|
|
481
|
-
npx noninteractive send workos
|
|
482
|
-
npx noninteractive send workos
|
|
483
|
-
npx noninteractive send workos
|
|
482
|
+
npx noninteractive send workos "" # press Enter (empty string = Enter)
|
|
483
|
+
npx noninteractive send workos "y\\r" # type "y" + Enter
|
|
484
|
+
npx noninteractive send workos "\\x1b[B\\r" # arrow down + Enter
|
|
485
|
+
npx noninteractive send workos "\\x1b[B" # arrow down (no Enter)
|
|
484
486
|
npx noninteractive read workos --wait # wait for new output (e.g. OAuth callback)
|
|
485
487
|
npx noninteractive stop workos # done, stop the session
|
|
486
488
|
|
|
@@ -663,6 +665,8 @@ async function read(name, wait, timeout, noOpen = false) {
|
|
|
663
665
|
async function send(name, text, wait, timeout, noOpen = false) {
|
|
664
666
|
if (text === "")
|
|
665
667
|
text = "\r";
|
|
668
|
+
text = text.replace(/\\x([0-9a-fA-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))).replace(/\\r/g, "\r").replace(/\\n/g, `
|
|
669
|
+
`).replace(/\\t/g, "\t");
|
|
666
670
|
const sock = socketPath(name);
|
|
667
671
|
if (wait) {
|
|
668
672
|
const res = await sendMessage(sock, { action: "sendread", data: text, timeout }, timeout + 5000);
|