noninteractive 0.3.20 → 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 +13 -6
- 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
|
|
|
@@ -488,7 +490,10 @@ more examples:
|
|
|
488
490
|
npx noninteractive vercel # session "vercel"
|
|
489
491
|
npx noninteractive supabase init # session "supabase"
|
|
490
492
|
npx noninteractive start vercel login # explicit start for non-npx commands`;
|
|
491
|
-
var stripAnsi = (s) => s.replace(/\x1b\[[
|
|
493
|
+
var stripAnsi = (s) => s.replace(/\x1b\[[012]?K/g, `
|
|
494
|
+
`).replace(/\x1b\[[\x20-\x3f]*[\x40-\x7e]|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[()][A-Z0-9]|\x1b[\x20-\x2f]*[\x30-\x7e]|\x07/g, "").replace(/\r\n?/g, `
|
|
495
|
+
`).replace(/\n{3,}/g, `
|
|
496
|
+
|
|
492
497
|
`);
|
|
493
498
|
var seenUrls = new Set;
|
|
494
499
|
function openUrl(url) {
|
|
@@ -660,6 +665,8 @@ async function read(name, wait, timeout, noOpen = false) {
|
|
|
660
665
|
async function send(name, text, wait, timeout, noOpen = false) {
|
|
661
666
|
if (text === "")
|
|
662
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");
|
|
663
670
|
const sock = socketPath(name);
|
|
664
671
|
if (wait) {
|
|
665
672
|
const res = await sendMessage(sock, { action: "sendread", data: text, timeout }, timeout + 5000);
|