noninteractive 0.3.30 → 0.3.33

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.
@@ -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.30",
407
+ version: "0.3.33",
408
408
  type: "module",
409
409
  bin: {
410
410
  noninteractive: "./bin/noninteractive.js"
@@ -681,25 +681,37 @@ 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
- let name = baseName;
685
- let suffix = 1;
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
- break;
694
+ for (let j = 0;j < 20; j++) {
695
+ if (!existsSync2(sock2))
696
+ break;
697
+ await new Promise((r) => setTimeout(r, 100));
698
+ }
699
+ try {
700
+ const { unlinkSync: unlinkSync2 } = await import("fs");
701
+ unlinkSync2(sock2);
702
+ } catch {}
703
+ } else {
704
+ console.error(`session '${name}' is already running. use a different --name or stop it first:`);
705
+ console.error(` npx noninteractive stop ${name}`);
706
+ process.exit(1);
696
707
  }
697
- suffix++;
698
- name = `${baseName}-${suffix}`;
699
- continue;
700
708
  }
701
- } catch {}
702
- break;
709
+ } catch {
710
+ try {
711
+ const { unlinkSync: unlinkSync2 } = await import("fs");
712
+ unlinkSync2(sock2);
713
+ } catch {}
714
+ }
703
715
  }
704
716
  const sock = socketPath(name);
705
717
  ensureSessionsDir();
@@ -739,15 +751,17 @@ make sure the command exists. examples:`);
739
751
  process.stdout.write(stripAnsi(res.output));
740
752
  if (res.exited) {
741
753
  console.log(`
742
- [session '${name}' exited ${res.exitCode} \u2014 the command failed]`);
743
- console.log(`hint: the first argument to "start" is the command to run, NOT a session name.`);
744
- console.log(` npx noninteractive start npx vercel # run an npx package`);
745
- console.log(` npx noninteractive start vercel login # run a command directly`);
754
+ [session '${name}' exited ${res.exitCode}]`);
755
+ if (clean.length < 100 && i < 10) {
756
+ console.log(`hint: the first argument to "start" is the command to run, NOT a session name.`);
757
+ console.log(` npx noninteractive start npx vercel # run an npx package`);
758
+ console.log(` npx noninteractive start vercel login # run a command directly`);
759
+ }
746
760
  } else {
747
761
  console.log(`
748
- [session '${name}' started \u2014 read the output above, then use:]`);
762
+ [session '${name}' started \u2014 the first prompt is shown above. use:]`);
749
763
  console.log(` npx noninteractive send ${name} "<text>" # send and get response (waits by default)`);
750
- console.log(` npx noninteractive read ${name} --wait # wait for NEW output (no sleep needed)`);
764
+ console.log(` npx noninteractive read ${name} --wait # only needed for long waits (e.g. OAuth, npm install)`);
751
765
  console.log(` npx noninteractive stop ${name} # stop the session`);
752
766
  }
753
767
  return;
@@ -755,8 +769,10 @@ make sure the command exists. examples:`);
755
769
  if (res.exited) {
756
770
  process.stdout.write(stripAnsi(res.output ?? ""));
757
771
  console.log(`
758
- [session '${name}' exited ${res.exitCode} \u2014 the command failed]`);
759
- console.log(`hint: the first argument to "start" is the command to run, NOT a session name.`);
772
+ [session '${name}' exited ${res.exitCode}]`);
773
+ if (i < 10) {
774
+ console.log(`hint: the first argument to "start" is the command to run, NOT a session name.`);
775
+ }
760
776
  console.log(` npx noninteractive start npx vercel # run an npx package`);
761
777
  console.log(` npx noninteractive start vercel login # run a command directly`);
762
778
  return;
@@ -765,7 +781,7 @@ make sure the command exists. examples:`);
765
781
  }
766
782
  console.log(`[session '${name}' started but no output yet \u2014 use:]`);
767
783
  console.log(` npx noninteractive send ${name} "<text>" # send and get response (waits by default)`);
768
- console.log(` npx noninteractive read ${name} --wait # wait for NEW output (no sleep needed)`);
784
+ console.log(` npx noninteractive read ${name} --wait # only needed for long waits (e.g. OAuth, npm install)`);
769
785
  console.log(` npx noninteractive stop ${name} # stop the session`);
770
786
  }
771
787
  async function read(name, wait, timeout, noOpen = false) {
@@ -781,9 +797,11 @@ async function read(name, wait, timeout, noOpen = false) {
781
797
  if (res.output !== undefined)
782
798
  process.stdout.write(stripAnsi(res.output));
783
799
  handleUrls(res, noOpen);
784
- if (res.exited)
800
+ if (res.exited) {
785
801
  console.log(`
786
802
  [exited ${res.exitCode}]`);
803
+ console.log(`[session complete \u2014 output above is final, no need to read again]`);
804
+ }
787
805
  } catch {
788
806
  const outputFile = sessionOutputFile(name);
789
807
  if (existsSync2(outputFile)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noninteractive",
3
- "version": "0.3.30",
3
+ "version": "0.3.33",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "noninteractive": "./bin/noninteractive.js"