noninteractive 0.3.15 → 0.3.17
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 +37 -27
- package/package.json +1 -1
package/bin/noninteractive.js
CHANGED
|
@@ -347,7 +347,7 @@ var init_daemon = __esm(() => {
|
|
|
347
347
|
var require_package = __commonJS((exports, module) => {
|
|
348
348
|
module.exports = {
|
|
349
349
|
name: "noninteractive",
|
|
350
|
-
version: "0.3.
|
|
350
|
+
version: "0.3.17",
|
|
351
351
|
type: "module",
|
|
352
352
|
bin: {
|
|
353
353
|
noninteractive: "./bin/noninteractive.js"
|
|
@@ -512,10 +512,21 @@ function getSelfCommand() {
|
|
|
512
512
|
function deriveSessionName(cmd, args) {
|
|
513
513
|
const parts = [cmd, ...args];
|
|
514
514
|
let i = 0;
|
|
515
|
-
|
|
516
|
-
i
|
|
517
|
-
|
|
518
|
-
|
|
515
|
+
while (i < parts.length) {
|
|
516
|
+
if (parts[i] === "npx" || parts[i] === "bunx") {
|
|
517
|
+
i++;
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
if (parts[i] === "--") {
|
|
521
|
+
i++;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (parts[i].startsWith("-")) {
|
|
525
|
+
i++;
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
519
530
|
const name = parts[i] || cmd;
|
|
520
531
|
const stripped = name.replace(/(?<=.)@[^/].*$/, "");
|
|
521
532
|
return (stripped || name).replace(/^@[^/]+\//, "").replace(/[^a-zA-Z0-9_-]/g, "");
|
|
@@ -523,29 +534,28 @@ function deriveSessionName(cmd, args) {
|
|
|
523
534
|
async function start(cmdArgs, noOpen = false) {
|
|
524
535
|
const executable = cmdArgs[0];
|
|
525
536
|
const args = cmdArgs.slice(1);
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
if (res.
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
console.log(` npx noninteractive read ${name} --wait # wait for new output`);
|
|
544
|
-
console.log(` npx noninteractive stop ${name} # stop the session`);
|
|
545
|
-
return;
|
|
537
|
+
const baseName = deriveSessionName(executable, args);
|
|
538
|
+
let name = baseName;
|
|
539
|
+
let suffix = 1;
|
|
540
|
+
while (true) {
|
|
541
|
+
const sock2 = socketPath(name);
|
|
542
|
+
try {
|
|
543
|
+
const res = await sendMessage(sock2, { action: "read" });
|
|
544
|
+
if (res.ok) {
|
|
545
|
+
if (res.exited) {
|
|
546
|
+
try {
|
|
547
|
+
await sendMessage(sock2, { action: "stop" });
|
|
548
|
+
} catch {}
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
suffix++;
|
|
552
|
+
name = `${baseName}-${suffix}`;
|
|
553
|
+
continue;
|
|
546
554
|
}
|
|
547
|
-
}
|
|
548
|
-
|
|
555
|
+
} catch {}
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
558
|
+
const sock = socketPath(name);
|
|
549
559
|
ensureSessionsDir();
|
|
550
560
|
try {
|
|
551
561
|
const { unlinkSync: unlinkSync2 } = await import("fs");
|