MCPcopy Create free account
hub / github.com/alibaba/open-code-review / main

Function main

scripts/update.js:139–179  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137}
138
139async function main() {
140 touchTimestamp();
141
142 if (!acquireLock()) return;
143
144 try {
145 const resolved = resolveNativeBinary();
146 if (!resolved) return;
147
148 const installedVersion = getInstalledVersion(resolved.path);
149 if (!installedVersion) return;
150
151 const pkg = loadPackageJson();
152 const latestVersion = await fetchLatestVersion(pkg);
153 if (!latestVersion) return;
154
155 if (!SEMVER_RE.test(latestVersion)) return;
156
157 if (!semverGt(latestVersion, installedVersion)) {
158 removeHint();
159 return;
160 }
161
162 const pkgName = pkg.name;
163 const IS_WINDOWS = process.platform === "win32";
164 const result = spawnSync("npm", ["i", "-g", `${pkgName}@${latestVersion}`], {
165 encoding: "utf8",
166 timeout: 120000,
167 shell: IS_WINDOWS,
168 });
169
170 if (result.status === 0) {
171 removeHint();
172 } else {
173 writeHint(latestVersion, pkgName);
174 }
175 } catch (_) {
176 } finally {
177 releaseLock();
178 }
179}
180
181main().catch(() => {});

Callers 1

update.jsFile · 0.70

Calls 10

touchTimestampFunction · 0.85
acquireLockFunction · 0.85
resolveNativeBinaryFunction · 0.85
getInstalledVersionFunction · 0.85
loadPackageJsonFunction · 0.85
fetchLatestVersionFunction · 0.85
semverGtFunction · 0.85
removeHintFunction · 0.85
writeHintFunction · 0.85
releaseLockFunction · 0.85

Tested by

no test coverage detected