plc-checkweigher 1.15.0 → 1.16.0
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/bin/cli.js +20 -14
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -86,28 +86,34 @@ function buildBanner() {
|
|
|
86
86
|
return lines.join('\n');
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
const STAMP_FILE = '/tmp/.plc-checkweigher-postinstall';
|
|
90
|
+
|
|
89
91
|
function showAccessDenied() {
|
|
90
92
|
const banner = buildBanner();
|
|
91
93
|
const isPostinstall = process.env.npm_lifecycle_event === 'postinstall';
|
|
92
94
|
|
|
93
95
|
if (isPostinstall) {
|
|
94
|
-
// npm 7+ pipes away stdout/stderr
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
fs.closeSync(fd);
|
|
104
|
-
} catch (_) {
|
|
105
|
-
// No real terminal attached (CI, pipe) — silently skip.
|
|
106
|
-
}
|
|
107
|
-
}
|
|
96
|
+
// npm 7+ pipes away stdout/stderr — write directly to /dev/tty.
|
|
97
|
+
try {
|
|
98
|
+
const fd = fs.openSync('/dev/tty', 'w');
|
|
99
|
+
fs.writeSync(fd, banner + '\n');
|
|
100
|
+
fs.closeSync(fd);
|
|
101
|
+
} catch (_) {}
|
|
102
|
+
// Always stamp regardless of whether /dev/tty was available,
|
|
103
|
+
// so the CLI invocation npx runs right after skips the banner.
|
|
104
|
+
try { fs.writeFileSync(STAMP_FILE, String(Date.now())); } catch (_) {}
|
|
108
105
|
process.exit(0);
|
|
109
106
|
}
|
|
110
107
|
|
|
108
|
+
// Suppress duplicate: if postinstall printed the banner within the last 3s, skip.
|
|
109
|
+
try {
|
|
110
|
+
const ts = parseInt(fs.readFileSync(STAMP_FILE, 'utf8'), 10);
|
|
111
|
+
if (Date.now() - ts < 3000) {
|
|
112
|
+
fs.unlinkSync(STAMP_FILE);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
} catch (_) {}
|
|
116
|
+
|
|
111
117
|
console.log(banner);
|
|
112
118
|
process.exit(1);
|
|
113
119
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plc-checkweigher",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "One-command installer for the PLC Check-Weigher system on Raspberry Pi (PREEMPT_RT kernel, Python stack, WiFi, SMB, systemd RT services)",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"postinstall": "node bin/cli.js"
|