plc-checkweigher 1.14.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 +16 -5
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -86,23 +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
|
-
// Write directly to /dev/tty so it reaches the terminal regardless.
|
|
96
|
+
// npm 7+ pipes away stdout/stderr — write directly to /dev/tty.
|
|
96
97
|
try {
|
|
97
98
|
const fd = fs.openSync('/dev/tty', 'w');
|
|
98
99
|
fs.writeSync(fd, banner + '\n');
|
|
99
100
|
fs.closeSync(fd);
|
|
100
|
-
} catch (_) {
|
|
101
|
-
|
|
102
|
-
|
|
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 (_) {}
|
|
103
105
|
process.exit(0);
|
|
104
106
|
}
|
|
105
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
|
+
|
|
106
117
|
console.log(banner);
|
|
107
118
|
process.exit(1);
|
|
108
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"
|