@kaynooo/cli-pick 0.6.0 → 0.6.1

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.
Files changed (2) hide show
  1. package/dist/pick.js +19 -6
  2. package/package.json +2 -2
package/dist/pick.js CHANGED
@@ -1004,6 +1004,8 @@ async function runMain({ name, version, run, redact, usage }, argv = process11.a
1004
1004
  }
1005
1005
  return code;
1006
1006
  }
1007
+ // ../kit/src/folders.ts
1008
+ var SKIPPED_FOLDERS = new Set(["node_modules", "vendor", "dist", "build", "target", "coverage", "venv", "__pycache__"]);
1007
1009
  // ../kit/src/secrets.ts
1008
1010
  var SECRET_WORDS = new Set(["key", "pass", "pwd", "auth", "salt", "cookie", "session", "jwt", "ssn", "iban", "card", "cvv", "otp"]);
1009
1011
  // ../kit/src/sessions.ts
@@ -1485,14 +1487,24 @@ function up(lines) {
1485
1487
  return lines > 0 ? `\x1B[${lines}A` : "";
1486
1488
  }
1487
1489
  function openTerminal() {
1488
- let input;
1490
+ let mode;
1489
1491
  try {
1490
- input = new tty.ReadStream(openSync("/dev/tty", "r"));
1492
+ mode = new tty.ReadStream(openSync("/dev/tty", "r"));
1491
1493
  } catch {
1492
1494
  return fail("no terminal to read keys from (/dev/tty)");
1493
1495
  }
1496
+ const keys = Bun.file("/dev/tty").stream().getReader();
1494
1497
  const out = process14.stderr;
1495
1498
  let resize;
1499
+ async function read(onChunk) {
1500
+ const decoder = new TextDecoder;
1501
+ try {
1502
+ for (let chunk = await keys.read();!chunk.done; chunk = await keys.read())
1503
+ onChunk(decoder.decode(chunk.value, { stream: true }));
1504
+ } catch {
1505
+ onChunk("\x03");
1506
+ }
1507
+ }
1496
1508
  return {
1497
1509
  get columns() {
1498
1510
  return out.columns || 80;
@@ -1504,17 +1516,18 @@ function openTerminal() {
1504
1516
  write: (text) => void out.write(text),
1505
1517
  listen(onChunk, onResize) {
1506
1518
  resize = onResize;
1507
- input.setRawMode(true);
1519
+ mode.setRawMode(true);
1508
1520
  out.on("resize", onResize);
1509
- input.on("data", (chunk) => onChunk(chunk.toString()));
1521
+ read(onChunk);
1510
1522
  },
1511
1523
  close() {
1512
1524
  if (resize !== undefined)
1513
1525
  out.off("resize", resize);
1514
1526
  try {
1515
- input.setRawMode(false);
1527
+ mode.setRawMode(false);
1516
1528
  } finally {
1517
- input.destroy();
1529
+ mode.destroy();
1530
+ keys.cancel();
1518
1531
  }
1519
1532
  }
1520
1533
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaynooo/cli-pick",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "description": "pick: a themed fuzzy selector, lines on stdin, the chosen one on stdout.",
6
6
  "author": "Kaynooo <contact@kaynooo.fr>",
7
7
  "license": "MIT",
@@ -35,6 +35,6 @@
35
35
  "pick": "$npm_execpath src/pick.ts"
36
36
  },
37
37
  "devDependencies": {
38
- "@kaynooo/cli-kit": "0.26.0"
38
+ "@kaynooo/cli-kit": "0.27.1"
39
39
  }
40
40
  }