windsor-bot 0.1.13 → 0.1.15

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.
@@ -9,16 +9,25 @@ export class PrinterUnavailableError extends Error {
9
9
  }
10
10
  }
11
11
  function isUnavailableError(error) {
12
- if (!(error instanceof Error))
13
- return false;
14
- const code = 'code' in error ? error.code : undefined;
15
- const message = error.message.toLowerCase();
16
- return code === 'ENOENT' ||
17
- code === 'ENODEV' ||
18
- code === 'ENXIO' ||
19
- message.includes('printer or class does not exist') ||
20
- message.includes('no printer') ||
21
- message.includes('device or resource busy');
12
+ let current = error;
13
+ for (let depth = 0; depth < 4 && current; depth++) {
14
+ if (!(current instanceof Error))
15
+ return false;
16
+ const code = 'code' in current ? String(current.code) : '';
17
+ const message = `${current.name} ${current.message}`.toLowerCase();
18
+ if (code === 'ENOENT' ||
19
+ code === 'ENODEV' ||
20
+ code === 'ENXIO' ||
21
+ message.includes('enoent') ||
22
+ message.includes('no such file or directory') ||
23
+ message.includes('printer or class does not exist') ||
24
+ message.includes('no printer') ||
25
+ message.includes('device or resource busy')) {
26
+ return true;
27
+ }
28
+ current = 'cause' in current ? current.cause : undefined;
29
+ }
30
+ return false;
22
31
  }
23
32
  export async function printJob(job) {
24
33
  const cfg = getCurrentConfig();
package/dist/server.js CHANGED
@@ -65,8 +65,13 @@ async function readPackageVersion() {
65
65
  return packageJson.version;
66
66
  }
67
67
  async function updateGlobalBot() {
68
- await execFileAsync('npm', ['install', '-g', 'windsor-bot@latest']);
69
- const { stdout } = await execFileAsync('npm', ['root', '-g']);
68
+ // GUI-launched processes may not inherit the shell PATH where npm is installed.
69
+ const npmEnv = {
70
+ ...process.env,
71
+ PATH: [dirname(process.execPath), process.env.PATH].filter(Boolean).join(process.platform === 'win32' ? ';' : ':'),
72
+ };
73
+ await execFileAsync('npm', ['install', '-g', 'windsor-bot@latest'], { env: npmEnv });
74
+ const { stdout } = await execFileAsync('npm', ['root', '-g'], { env: npmEnv });
70
75
  const packageJsonPath = join(stdout.trim(), 'windsor-bot', 'package.json');
71
76
  const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf8'));
72
77
  if (typeof packageJson.version !== 'string')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windsor-bot",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Self-hosted Discord bot automation for household list and todo printing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",