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.
Files changed (2) hide show
  1. package/lib/tunnel.mjs +15 -6
  2. 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 bin = join(cacheDir, `cloudflared${platformBinary().ext}`);
296
- try {
297
- await access(bin);
298
- return bin; // 缓存命中,秒开
299
- } catch { /* 缓存缺失,下载 */ }
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(bin, signal).finally(() => { downloading = null; });
312
+ downloading = downloadCloudflared(join(cacheDir, `cloudflared${ext}`), signal).finally(() => { downloading = null; });
304
313
  }
305
314
  return downloading;
306
315
  }
package/package.json CHANGED
@@ -76,5 +76,5 @@
76
76
  "access": "public",
77
77
  "registry": "https://registry.npmjs.org/"
78
78
  },
79
- "version": "1.7.1"
79
+ "version": "1.7.2"
80
80
  }