plugin-updater 1.0.26 → 1.0.27

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/index.js +15 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ function writeLog(message, isError = false) {
53
53
  else if (loggingEnabled)
54
54
  console.log(message);
55
55
  }
56
+ let NPM_GLOBAL_ROOT = null;
56
57
  function getReposDir() {
57
58
  const isClaude = process.argv.join(" ").includes("claude");
58
59
  const appName = isClaude ? "claude" : "opencode";
@@ -75,17 +76,26 @@ function executeGit(command, cwd) {
75
76
  return false;
76
77
  }
77
78
  }
79
+ function getNpmGlobalRoot() {
80
+ if (NPM_GLOBAL_ROOT !== null)
81
+ return NPM_GLOBAL_ROOT;
82
+ try {
83
+ NPM_GLOBAL_ROOT = execSync("npm root -g", { stdio: ["ignore", "pipe", "ignore"] }).toString().trim();
84
+ }
85
+ catch {
86
+ NPM_GLOBAL_ROOT = "";
87
+ }
88
+ return NPM_GLOBAL_ROOT;
89
+ }
78
90
  function resolveNpmPluginVersion(name, configDir) {
79
91
  try {
80
92
  const cacheDir = path.join(configDir, "cache", "node_modules");
81
- const globalNpm = process.platform === "win32"
82
- ? path.join(os.homedir(), "AppData", "Roaming", "npm", "node_modules")
83
- : path.join("/usr", "lib", "node_modules");
93
+ const globalNpm = getNpmGlobalRoot();
84
94
  const candidates = [
85
95
  path.join(cacheDir, name, "package.json"),
86
96
  path.join(configDir, "node_modules", name, "package.json"),
87
- path.join(globalNpm, name, "package.json"),
88
- ];
97
+ globalNpm ? path.join(globalNpm, name, "package.json") : "",
98
+ ].filter((p) => p !== "");
89
99
  for (const p of candidates) {
90
100
  if (fs.existsSync(p)) {
91
101
  return JSON.parse(fs.readFileSync(p, "utf8")).version || "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-updater",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "Plugin lifecycle manager for OpenCode and Claude Code launchers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",