From 9a7cd9f937de0a16ef5b4e339429444ce74f5f18 Mon Sep 17 00:00:00 2001 From: GK012 <2365742220@qq.com> Date: Wed, 6 May 2026 23:19:05 +0800 Subject: [PATCH] fix(npm): add --version fallback in wrapper fix(npm): add --version fallback in wrapper --- npm/deepseek-tui/scripts/run.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/npm/deepseek-tui/scripts/run.js b/npm/deepseek-tui/scripts/run.js index 07f18cb5..23b71321 100644 --- a/npm/deepseek-tui/scripts/run.js +++ b/npm/deepseek-tui/scripts/run.js @@ -1,12 +1,34 @@ const { spawnSync } = require("child_process"); const { getBinaryPath } = require("./install"); +const pkg = require("../package.json"); + +function isVersionFlag() { + const args = process.argv.slice(2); + return args.includes("--version") || args.includes("-v") || args.includes("-V"); +} + +function handleVersionFallback(binaryName) { + if (isVersionFlag()) { + const binVersion = pkg.deepseekBinaryVersion || pkg.version; + console.log(`${binaryName} (npm wrapper) v${pkg.version}`); + console.log(`binary version: v${binVersion}`); + console.log(`repo: ${pkg.repository?.url || "N/A"}`); + process.exit(0); + } +} + async function run(binaryName) { + // Intercept --version before attempting binary download/launch + handleVersionFallback(binaryName); + const binaryPath = await getBinaryPath(binaryName); const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: "inherit", }); if (result.error) { + // If binary fails and user asked for --version, show npm version instead + handleVersionFallback(binaryName); throw result.error; } process.exit(result.status ?? 1);