windsor-bot 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/server.js +20 -9
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -65,27 +65,38 @@ async function readPackageVersion() {
65
65
  return packageJson.version;
66
66
  }
67
67
  async function updateGlobalBot() {
68
- const npmCliCandidates = [
68
+ const npmCandidates = [
69
69
  process.env['npm_execpath'],
70
70
  join(dirname(process.execPath), '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
71
+ join(dirname(process.execPath), 'npm'),
71
72
  '/usr/local/lib/node_modules/npm/bin/npm-cli.js',
72
73
  '/opt/homebrew/lib/node_modules/npm/bin/npm-cli.js',
73
- ].filter((candidate) => Boolean(candidate));
74
- let npmCliPath;
75
- for (const candidate of npmCliCandidates) {
74
+ '/usr/lib/node_modules/npm/bin/npm-cli.js',
75
+ '/usr/share/nodejs/npm/bin/npm-cli.js',
76
+ '/usr/local/bin/npm',
77
+ '/opt/homebrew/bin/npm',
78
+ '/usr/bin/npm',
79
+ ]
80
+ .filter((candidate) => Boolean(candidate))
81
+ .map(candidate => ({
82
+ path: candidate.endsWith('.js') ? process.execPath : candidate,
83
+ args: candidate.endsWith('.js') ? [candidate] : [],
84
+ }));
85
+ let npmCommand;
86
+ for (const candidate of npmCandidates) {
76
87
  try {
77
- await access(candidate);
78
- npmCliPath = candidate;
88
+ await access(candidate.path);
89
+ npmCommand = candidate;
79
90
  break;
80
91
  }
81
92
  catch {
82
93
  // Try the next known npm installation location.
83
94
  }
84
95
  }
85
- if (!npmCliPath)
96
+ if (!npmCommand)
86
97
  throw new Error('Unable to locate npm');
87
- const npmCli = npmCliPath;
88
- const runNpm = (args) => execFileAsync(process.execPath, [npmCli, ...args]);
98
+ const npm = npmCommand;
99
+ const runNpm = (args) => execFileAsync(npm.path, [...npm.args, ...args], { env: process.env });
89
100
  await runNpm(['install', '-g', 'windsor-bot@latest']);
90
101
  const { stdout } = await runNpm(['root', '-g']);
91
102
  const packageJsonPath = join(stdout.trim(), 'windsor-bot', 'package.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windsor-bot",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Self-hosted Discord bot automation for household list and todo printing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",