layero 0.1.5 → 0.1.7
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/scripts/postinstall.cjs +33 -16
package/package.json
CHANGED
package/scripts/postinstall.cjs
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Print a quick-start banner after `npm install -g layero`.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
//
|
|
4
|
+
// npm 10+ buffers postinstall stdout AND stderr (foreground-scripts=false
|
|
5
|
+
// by default), so writing to either is invisible unless the script fails
|
|
6
|
+
// or the user passes --foreground-scripts. Workaround: write directly to
|
|
7
|
+
// the controlling terminal at /dev/tty, which bypasses npm's pipe.
|
|
8
|
+
//
|
|
9
|
+
// On Windows there's no /dev/tty; we fall back to stderr (which Windows
|
|
10
|
+
// npm doesn't buffer the same way) and silently skip on any error.
|
|
5
11
|
|
|
6
12
|
if (process.env.CI) return;
|
|
7
13
|
if (process.env.LAYERO_SKIP_POSTINSTALL) return;
|
|
8
|
-
if (!process.stdout.isTTY) return;
|
|
9
14
|
|
|
10
|
-
// Only print when the
|
|
11
|
-
//
|
|
12
|
-
// we check that this package is the install target via npm_package_name.
|
|
15
|
+
// Only print when `layero` is the install target — not when it's pulled
|
|
16
|
+
// in as a transitive dep of another package.
|
|
13
17
|
const isGlobal = process.env.npm_config_global === "true";
|
|
14
18
|
const isDirect = process.env.npm_package_name === "layero";
|
|
15
19
|
if (!isGlobal && !isDirect) return;
|
|
16
20
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const fs = require("node:fs");
|
|
22
|
+
|
|
23
|
+
const c = {
|
|
24
|
+
reset: "\x1b[0m",
|
|
25
|
+
bold: "\x1b[1m",
|
|
26
|
+
dim: "\x1b[2m",
|
|
27
|
+
cyan: "\x1b[36m",
|
|
28
|
+
green: "\x1b[32m",
|
|
29
|
+
};
|
|
26
30
|
|
|
27
31
|
const lines = [
|
|
28
32
|
"",
|
|
@@ -35,4 +39,17 @@ const lines = [
|
|
|
35
39
|
` ${c.dim}Docs: https://layero.ru${c.reset}`,
|
|
36
40
|
"",
|
|
37
41
|
];
|
|
38
|
-
|
|
42
|
+
const banner = lines.join("\n");
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
if (process.platform === "win32") {
|
|
46
|
+
process.stderr.write(banner);
|
|
47
|
+
} else {
|
|
48
|
+
// Open the controlling tty directly. This bypasses npm's stdio pipes.
|
|
49
|
+
const fd = fs.openSync("/dev/tty", "w");
|
|
50
|
+
fs.writeSync(fd, banner);
|
|
51
|
+
fs.closeSync(fd);
|
|
52
|
+
}
|
|
53
|
+
} catch {
|
|
54
|
+
// Headless install (no tty), or perms issue — give up silently.
|
|
55
|
+
}
|