noninteractive 0.3.9 → 0.3.11

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.
@@ -243,7 +243,7 @@ var init_daemon = __esm(() => {
243
243
  var require_package = __commonJS((exports, module) => {
244
244
  module.exports = {
245
245
  name: "noninteractive",
246
- version: "0.3.9",
246
+ version: "0.3.11",
247
247
  type: "module",
248
248
  bin: {
249
249
  noninteractive: "./bin/noninteractive.js"
@@ -362,6 +362,8 @@ more examples:
362
362
  npx noninteractive vercel # session "vercel"
363
363
  npx noninteractive supabase init # session "supabase"
364
364
  npx noninteractive start vercel login # explicit start for non-npx commands`;
365
+ var stripAnsi = (s) => s.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, `
366
+ `);
365
367
  function getSelfCommand() {
366
368
  const script = process.argv[1];
367
369
  if (!script)
@@ -396,7 +398,7 @@ async function start(cmdArgs) {
396
398
  try {
397
399
  const res = await sendMessage(sock, { action: "read" });
398
400
  if (res.ok) {
399
- process.stdout.write(res.output ?? "");
401
+ process.stdout.write(stripAnsi(res.output ?? ""));
400
402
  if (res.exited) {
401
403
  console.log(`
402
404
  [session '${name}' already exists but exited ${res.exitCode} \u2014 stopping it]`);
@@ -438,14 +440,13 @@ make sure the command exists. examples:`);
438
440
  console.error(` npx noninteractive start vercel login # run a command directly`);
439
441
  process.exit(1);
440
442
  }
441
- const stripAnsi = (s) => s.replace(/\x1b\[[0-9;]*[a-zA-Z]|\x1b\][^\x07]*\x07/g, "");
442
443
  for (let i = 0;i < 50; i++) {
443
444
  await new Promise((r) => setTimeout(r, 200));
444
445
  try {
445
446
  const res = await sendMessage(sock, { action: "read" });
446
447
  const clean = stripAnsi(res.output ?? "").trim();
447
448
  if (clean.length > 10) {
448
- process.stdout.write(res.output);
449
+ process.stdout.write(stripAnsi(res.output));
449
450
  if (res.exited) {
450
451
  console.log(`
451
452
  [session '${name}' exited ${res.exitCode} \u2014 the command failed]`);
@@ -462,7 +463,7 @@ make sure the command exists. examples:`);
462
463
  return;
463
464
  }
464
465
  if (res.exited) {
465
- process.stdout.write(res.output ?? "");
466
+ process.stdout.write(stripAnsi(res.output ?? ""));
466
467
  console.log(`
467
468
  [session '${name}' exited ${res.exitCode} \u2014 the command failed]`);
468
469
  console.log(`hint: the first argument to "start" is the command to run, NOT a session name.`);
@@ -487,7 +488,7 @@ async function read(name, wait, timeout) {
487
488
  const clientTimeout = wait ? timeout + 5000 : 5000;
488
489
  const res = await sendMessage(sock, msg, clientTimeout);
489
490
  if (res.output !== undefined)
490
- process.stdout.write(res.output);
491
+ process.stdout.write(stripAnsi(res.output));
491
492
  if (res.exited)
492
493
  console.log(`
493
494
  [exited ${res.exitCode}]`);
@@ -497,7 +498,7 @@ async function send(name, text, wait, timeout) {
497
498
  if (wait) {
498
499
  const res = await sendMessage(sock, { action: "sendread", data: text, timeout }, timeout + 5000);
499
500
  if (res.output !== undefined)
500
- process.stdout.write(res.output);
501
+ process.stdout.write(stripAnsi(res.output));
501
502
  if (res.exited)
502
503
  console.log(`
503
504
  [exited ${res.exitCode}]`);
@@ -606,7 +607,8 @@ example: npx noninteractive stop vercel`);
606
607
  console.log(HELP);
607
608
  break;
608
609
  default:
609
- return start(["npx", ...args]);
610
+ console.log(`[installing and running: npx ${args.join(" ")}]`);
611
+ return start(["npx", "--yes", ...args]);
610
612
  }
611
613
  }
612
614
  main().catch((err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noninteractive",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "noninteractive": "./bin/noninteractive.js"