noninteractive 0.3.30 → 0.3.32
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 +27 -20
- package/package.json +1 -1
package/bin/noninteractive.js
CHANGED
|
@@ -404,7 +404,7 @@ var init_daemon = __esm(() => {
|
|
|
404
404
|
var require_package = __commonJS((exports, module) => {
|
|
405
405
|
module.exports = {
|
|
406
406
|
name: "noninteractive",
|
|
407
|
-
version: "0.3.
|
|
407
|
+
version: "0.3.32",
|
|
408
408
|
type: "module",
|
|
409
409
|
bin: {
|
|
410
410
|
noninteractive: "./bin/noninteractive.js"
|
|
@@ -681,25 +681,28 @@ async function start(cmdArgs, noOpen = false, sessionName, cwd) {
|
|
|
681
681
|
const executable = cmdArgs[0];
|
|
682
682
|
const args = cmdArgs.slice(1);
|
|
683
683
|
const baseName = sessionName || deriveSessionName(executable, args);
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
while (true) {
|
|
684
|
+
const name = baseName;
|
|
685
|
+
{
|
|
687
686
|
const sock2 = socketPath(name);
|
|
688
687
|
try {
|
|
689
|
-
const res = await sendMessage(sock2, { action: "read" });
|
|
688
|
+
const res = await sendMessage(sock2, { action: "read" }, 2000);
|
|
690
689
|
if (res.ok) {
|
|
691
690
|
if (res.exited) {
|
|
692
691
|
try {
|
|
693
|
-
await sendMessage(sock2, { action: "stop" });
|
|
692
|
+
await sendMessage(sock2, { action: "stop" }, 2000);
|
|
694
693
|
} catch {}
|
|
695
|
-
|
|
694
|
+
} else {
|
|
695
|
+
console.error(`session '${name}' is already running. use a different --name or stop it first:`);
|
|
696
|
+
console.error(` npx noninteractive stop ${name}`);
|
|
697
|
+
process.exit(1);
|
|
696
698
|
}
|
|
697
|
-
suffix++;
|
|
698
|
-
name = `${baseName}-${suffix}`;
|
|
699
|
-
continue;
|
|
700
699
|
}
|
|
701
|
-
} catch {
|
|
702
|
-
|
|
700
|
+
} catch {
|
|
701
|
+
try {
|
|
702
|
+
const { unlinkSync: unlinkSync2 } = await import("fs");
|
|
703
|
+
unlinkSync2(sock2);
|
|
704
|
+
} catch {}
|
|
705
|
+
}
|
|
703
706
|
}
|
|
704
707
|
const sock = socketPath(name);
|
|
705
708
|
ensureSessionsDir();
|
|
@@ -739,15 +742,17 @@ make sure the command exists. examples:`);
|
|
|
739
742
|
process.stdout.write(stripAnsi(res.output));
|
|
740
743
|
if (res.exited) {
|
|
741
744
|
console.log(`
|
|
742
|
-
[session '${name}' exited ${res.exitCode}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
745
|
+
[session '${name}' exited ${res.exitCode}]`);
|
|
746
|
+
if (clean.length < 100 && i < 10) {
|
|
747
|
+
console.log(`hint: the first argument to "start" is the command to run, NOT a session name.`);
|
|
748
|
+
console.log(` npx noninteractive start npx vercel # run an npx package`);
|
|
749
|
+
console.log(` npx noninteractive start vercel login # run a command directly`);
|
|
750
|
+
}
|
|
746
751
|
} else {
|
|
747
752
|
console.log(`
|
|
748
|
-
[session '${name}' started \u2014
|
|
753
|
+
[session '${name}' started \u2014 the first prompt is shown above. use:]`);
|
|
749
754
|
console.log(` npx noninteractive send ${name} "<text>" # send and get response (waits by default)`);
|
|
750
|
-
console.log(` npx noninteractive read ${name} --wait #
|
|
755
|
+
console.log(` npx noninteractive read ${name} --wait # only needed for long waits (e.g. OAuth, npm install)`);
|
|
751
756
|
console.log(` npx noninteractive stop ${name} # stop the session`);
|
|
752
757
|
}
|
|
753
758
|
return;
|
|
@@ -765,7 +770,7 @@ make sure the command exists. examples:`);
|
|
|
765
770
|
}
|
|
766
771
|
console.log(`[session '${name}' started but no output yet \u2014 use:]`);
|
|
767
772
|
console.log(` npx noninteractive send ${name} "<text>" # send and get response (waits by default)`);
|
|
768
|
-
console.log(` npx noninteractive read ${name} --wait #
|
|
773
|
+
console.log(` npx noninteractive read ${name} --wait # only needed for long waits (e.g. OAuth, npm install)`);
|
|
769
774
|
console.log(` npx noninteractive stop ${name} # stop the session`);
|
|
770
775
|
}
|
|
771
776
|
async function read(name, wait, timeout, noOpen = false) {
|
|
@@ -781,9 +786,11 @@ async function read(name, wait, timeout, noOpen = false) {
|
|
|
781
786
|
if (res.output !== undefined)
|
|
782
787
|
process.stdout.write(stripAnsi(res.output));
|
|
783
788
|
handleUrls(res, noOpen);
|
|
784
|
-
if (res.exited)
|
|
789
|
+
if (res.exited) {
|
|
785
790
|
console.log(`
|
|
786
791
|
[exited ${res.exitCode}]`);
|
|
792
|
+
console.log(`[session complete \u2014 output above is final, no need to read again]`);
|
|
793
|
+
}
|
|
787
794
|
} catch {
|
|
788
795
|
const outputFile = sessionOutputFile(name);
|
|
789
796
|
if (existsSync2(outputFile)) {
|