windsor-bot 0.2.12 → 0.2.13

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 +10 -7
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -87,8 +87,11 @@ async function updateGlobalBot() {
87
87
  try {
88
88
  const nodeVersions = await readdir(join(nvmDir, 'versions', 'node'), { withFileTypes: true });
89
89
  for (const version of nodeVersions) {
90
- if (version.isDirectory())
91
- nvmCandidates.push(join(nvmDir, 'versions', 'node', version.name, 'bin', 'npm'));
90
+ if (version.isDirectory()) {
91
+ const versionRoot = join(nvmDir, 'versions', 'node', version.name);
92
+ nvmCandidates.push(join(versionRoot, 'bin', 'npm'));
93
+ nvmCandidates.push(join(versionRoot, 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'));
94
+ }
92
95
  }
93
96
  logEvent('info', `Found ${nvmCandidates.length} nvm npm candidate(s) under ${nvmDir}`);
94
97
  }
@@ -106,11 +109,11 @@ async function updateGlobalBot() {
106
109
  logEvent('info', `Update requested; checking ${npmCandidates.length} npm candidate(s) (node=${process.execPath}, cwd=${process.cwd()})`);
107
110
  let npmCommand;
108
111
  for (const candidate of npmCandidates) {
109
- const nvmBin = candidate.match(/(\/\.nvm\/versions\/node\/[^/]+\/bin)\/npm$/)?.[1];
110
- const command = nvmBin
112
+ const nvmRoot = candidate.match(/(\/\.nvm\/versions\/node\/[^/]+)(?:\/bin\/npm|\/lib\/node_modules\/npm\/bin\/npm-cli\.js)$/)?.[1];
113
+ const command = nvmRoot
111
114
  ? {
112
- path: join(nvmBin, 'node'),
113
- args: [join(nvmBin, '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js')],
115
+ path: join(nvmRoot, 'bin', 'node'),
116
+ args: [join(nvmRoot, 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js')],
114
117
  }
115
118
  : candidate.endsWith('.js')
116
119
  ? { path: process.execPath, args: [candidate] }
@@ -118,7 +121,7 @@ async function updateGlobalBot() {
118
121
  try {
119
122
  // Validate the script itself, not just the Node executable used to run it.
120
123
  await access(candidate, constants.R_OK | (candidate.endsWith('.js') ? 0 : constants.X_OK));
121
- if (nvmBin) {
124
+ if (nvmRoot) {
122
125
  await access(command.path, constants.X_OK);
123
126
  await access(command.args[0], constants.R_OK);
124
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windsor-bot",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Self-hosted Discord bot automation for household list and todo printing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",