plc-checkweigher 1.28.0 → 1.28.2
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 +5 -25
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -86,35 +86,15 @@ function buildBanner() {
|
|
|
86
86
|
return lines.join('\n');
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
const STAMP_FILE = '/tmp/.plc-checkweigher-postinstall';
|
|
90
|
-
|
|
91
89
|
function showAccessDenied() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
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 (_) {}
|
|
90
|
+
// During npm install the binary hasn't been invoked yet — exit silently.
|
|
91
|
+
// The banner only makes sense when someone runs the binary directly
|
|
92
|
+
// without a valid subcommand (e.g. bare `npx plc-checkweigher`).
|
|
93
|
+
if (process.env.npm_lifecycle_event === 'postinstall') {
|
|
105
94
|
process.exit(0);
|
|
106
95
|
}
|
|
107
96
|
|
|
108
|
-
|
|
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
|
-
|
|
117
|
-
console.log(banner);
|
|
97
|
+
console.log(buildBanner());
|
|
118
98
|
process.exit(1);
|
|
119
99
|
}
|
|
120
100
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plc-checkweigher",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.2",
|
|
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"
|