dsh-pocket 1.7.1 → 1.7.2
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.
- package/lib/tunnel.mjs +15 -6
- package/package.json +1 -1
package/lib/tunnel.mjs
CHANGED
|
@@ -292,15 +292,24 @@ export async function resolveCloudflared({ home, onPhase = () => {}, signal } =
|
|
|
292
292
|
if (cloudflaredOnPath()) return 'cloudflared';
|
|
293
293
|
const dshHome = home ?? process.env.DSH_HOME ?? join(homedir(), '.dsh');
|
|
294
294
|
const cacheDir = join(dshHome, 'dsh-pocket', 'bin');
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
const { os, a, ext } = platformBinary();
|
|
296
|
+
// 缓存命中,兼容两种文件名(issue #15):
|
|
297
|
+
// 1) 本插件下载时写入的 bin 名:cloudflared.exe
|
|
298
|
+
// 2) 手动放置的**发布资产名**:cloudflared-windows-amd64.exe(与下载失败的错误提示一致)
|
|
299
|
+
const candidates = [
|
|
300
|
+
join(cacheDir, `cloudflared${ext}`),
|
|
301
|
+
join(cacheDir, `cloudflared-${os}-${a}${ext}`),
|
|
302
|
+
];
|
|
303
|
+
for (const bin of candidates) {
|
|
304
|
+
try {
|
|
305
|
+
await access(bin);
|
|
306
|
+
return bin; // 缓存命中,秒开
|
|
307
|
+
} catch { /* 继续找下一个 */ }
|
|
308
|
+
}
|
|
300
309
|
onPhase('downloading');
|
|
301
310
|
await mkdir(cacheDir, { recursive: true });
|
|
302
311
|
if (!downloading) {
|
|
303
|
-
downloading = downloadCloudflared(
|
|
312
|
+
downloading = downloadCloudflared(join(cacheDir, `cloudflared${ext}`), signal).finally(() => { downloading = null; });
|
|
304
313
|
}
|
|
305
314
|
return downloading;
|
|
306
315
|
}
|
package/package.json
CHANGED