sefy-cli 0.11.0 → 0.11.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/package.json +2 -2
  2. package/run.js +24 -1
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "sefy-cli",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "sefy": {
5
- "binary": "v0.11.0"
5
+ "binary": "v0.11.1"
6
6
  },
7
7
  "description": "An inconspicuous encrypted store for notes, credentials and files",
8
8
  "license": "MIT",
package/run.js CHANGED
@@ -2,12 +2,35 @@
2
2
  // Thin launcher: forwards everything to the sefy binary, downloading it on
3
3
  // first run when the postinstall script was skipped (npm v12 default).
4
4
  const fs = require("fs");
5
+ const os = require("os");
5
6
  const { spawnSync } = require("child_process");
6
7
  const { install, exePath } = require("./download");
7
8
 
9
+ // The keystrokes a terminal sends to every process on it, this launcher
10
+ // included. Left to the default, the launcher would die at once and hand the
11
+ // prompt back while sefy - or the command `sefy run` started - is still
12
+ // deciding what to do with the same keystroke. Listening keeps the launcher
13
+ // alive until the binary is done; the binary alone decides.
14
+ const KEYSTROKES =
15
+ process.platform === "win32" ? ["SIGINT", "SIGBREAK"] : ["SIGINT", "SIGQUIT"];
16
+
8
17
  function exec() {
18
+ const stayPut = () => {};
19
+ for (const signal of KEYSTROKES) process.on(signal, stayPut);
20
+
9
21
  const result = spawnSync(exePath, process.argv.slice(2), { stdio: "inherit" });
10
- process.exit(result.status === null ? 1 : result.status);
22
+ if (result.error) {
23
+ console.error(`sefy-cli: cannot start ${exePath}: ${result.error.message}`);
24
+ process.exit(1);
25
+ }
26
+ if (result.signal) {
27
+ // Ended by a signal: end the same way, so the shell reports it as it
28
+ // would for the binary run directly (130 after Ctrl+C), not as a plain 1.
29
+ for (const signal of KEYSTROKES) process.removeListener(signal, stayPut);
30
+ process.kill(process.pid, result.signal);
31
+ process.exit(128 + (os.constants.signals[result.signal] || 0));
32
+ }
33
+ process.exit(result.status);
11
34
  }
12
35
 
13
36
  if (fs.existsSync(exePath)) {