windsor-bot 0.2.9 → 0.2.11
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/dist/printing/escp.js +4 -5
- package/dist/server.js +18 -4
- package/package.json +1 -1
package/dist/printing/escp.js
CHANGED
|
@@ -24,11 +24,10 @@ function wrapText(text, width) {
|
|
|
24
24
|
return lines.length > 0 ? lines : [''];
|
|
25
25
|
}
|
|
26
26
|
function chooseFontForLines(totalLines) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return { fontSize: 'tall', cols: COLS_DOUBLE };
|
|
27
|
+
// Keep short messages large without relying on the printer's
|
|
28
|
+
// double-width glyph capacity, which varies by model and font.
|
|
29
|
+
if (totalLines <= 8) {
|
|
30
|
+
return { fontSize: 'tall', cols: COLS_NORMAL };
|
|
32
31
|
}
|
|
33
32
|
else {
|
|
34
33
|
return { fontSize: 'normal', cols: COLS_NORMAL };
|
package/dist/server.js
CHANGED
|
@@ -106,12 +106,22 @@ async function updateGlobalBot() {
|
|
|
106
106
|
logEvent('info', `Update requested; checking ${npmCandidates.length} npm candidate(s) (node=${process.execPath}, cwd=${process.cwd()})`);
|
|
107
107
|
let npmCommand;
|
|
108
108
|
for (const candidate of npmCandidates) {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
const nvmBin = candidate.match(/(\/\.nvm\/versions\/node\/[^/]+\/bin)\/npm$/)?.[1];
|
|
110
|
+
const command = nvmBin
|
|
111
|
+
? {
|
|
112
|
+
path: join(nvmBin, 'node'),
|
|
113
|
+
args: [join(nvmBin, '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js')],
|
|
114
|
+
}
|
|
115
|
+
: candidate.endsWith('.js')
|
|
116
|
+
? { path: process.execPath, args: [candidate] }
|
|
117
|
+
: { path: candidate, args: [] };
|
|
112
118
|
try {
|
|
113
119
|
// Validate the script itself, not just the Node executable used to run it.
|
|
114
120
|
await access(candidate, constants.R_OK | (candidate.endsWith('.js') ? 0 : constants.X_OK));
|
|
121
|
+
if (nvmBin) {
|
|
122
|
+
await access(command.path, constants.X_OK);
|
|
123
|
+
await access(command.args[0], constants.R_OK);
|
|
124
|
+
}
|
|
115
125
|
npmCommand = command;
|
|
116
126
|
logEvent('info', `Using npm candidate ${candidate}${command.args.length > 0 ? ` via ${command.path}` : ''}`);
|
|
117
127
|
break;
|
|
@@ -127,11 +137,15 @@ async function updateGlobalBot() {
|
|
|
127
137
|
throw new Error('Unable to locate an executable npm; see diagnostics');
|
|
128
138
|
}
|
|
129
139
|
const npm = npmCommand;
|
|
140
|
+
const nvmPrefix = npm.path.match(/(\/\.nvm\/versions\/node\/[^/]+)\/bin\/node$/)?.[1];
|
|
141
|
+
const npmEnv = nvmPrefix
|
|
142
|
+
? { ...process.env, NPM_CONFIG_PREFIX: nvmPrefix }
|
|
143
|
+
: process.env;
|
|
130
144
|
const runNpm = async (args) => {
|
|
131
145
|
const commandArgs = [...npm.args, ...args];
|
|
132
146
|
logEvent('info', `Running npm: ${npm.path} ${commandArgs.join(' ')}`);
|
|
133
147
|
try {
|
|
134
|
-
const result = await execFileAsync(npm.path, commandArgs, { env:
|
|
148
|
+
const result = await execFileAsync(npm.path, commandArgs, { env: npmEnv });
|
|
135
149
|
logEvent('info', `npm completed successfully: ${args.join(' ')}`);
|
|
136
150
|
return result;
|
|
137
151
|
}
|