catylst 1.0.11 → 1.0.12
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/package.json +1 -1
- package/postinstall.js +10 -18
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -35,20 +35,19 @@ const bold = (s) => `\x1b[1m${s}\x1b[0m`;
|
|
|
35
35
|
const dim = (s) => `\x1b[2m${s}\x1b[0m`;
|
|
36
36
|
const purple = (s) => `\x1b[35m${s}\x1b[0m`;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
/*
|
|
39
|
+
* npm v7+ pipes ALL postinstall stdout/stderr — nothing reaches the terminal.
|
|
40
|
+
* fs.writeSync on /dev/tty bypasses the pipe synchronously; no open handles,
|
|
41
|
+
* no event-loop delay, process exits the moment the last write completes.
|
|
42
|
+
* Falls back to stderr fd (2) on CI / Windows where /dev/tty is unavailable.
|
|
43
|
+
*/
|
|
44
|
+
let ttyFd = 2;
|
|
42
45
|
try {
|
|
43
|
-
// accessSync throws on CI/Windows where /dev/tty doesn't exist or isn't writable.
|
|
44
|
-
// Only open the stream if the device is confirmed accessible.
|
|
45
46
|
fs.accessSync("/dev/tty", fs.constants.W_OK);
|
|
46
|
-
|
|
47
|
-
t.on("error", () => {}); // suppress errors — fallback already set above
|
|
48
|
-
tty = t;
|
|
47
|
+
ttyFd = fs.openSync("/dev/tty", "w");
|
|
49
48
|
} catch (_) {}
|
|
50
|
-
const print = (s) =>
|
|
51
|
-
const printRaw = (s) =>
|
|
49
|
+
const print = (s) => fs.writeSync(ttyFd, s + "\n");
|
|
50
|
+
const printRaw = (s) => fs.writeSync(ttyFd, s);
|
|
52
51
|
|
|
53
52
|
// ── Tips & jokes shown while cloning / downloading ───────────────────────────
|
|
54
53
|
|
|
@@ -273,11 +272,4 @@ function downloadJar() {
|
|
|
273
272
|
print(" " + dim("Or non-interactive:"));
|
|
274
273
|
print(" " + dim("catylst --package com.example.app --name MyApp"));
|
|
275
274
|
print("");
|
|
276
|
-
|
|
277
|
-
// The /dev/tty WriteStream holds the event loop open after all output is
|
|
278
|
-
// written, making the process appear to hang. Close it so the process exits
|
|
279
|
-
// on its own without npm having to send SIGINT.
|
|
280
|
-
if (tty !== process.stderr) {
|
|
281
|
-
tty.end(() => process.exit(0));
|
|
282
|
-
}
|
|
283
275
|
})();
|