fix: resolve DEP0190 deprecation warning on Windows#87
Open
dengmik-commits wants to merge 1 commit into
Open
Conversation
Join command+args into a single string before passing to spawn with shell: true to avoid Node.js DEP0190 warning on Windows. Affected calls: - McpClient.connect() in mcp-client.ts - runNpmInstallGlobal() in updateCheck.ts - npmViewVersion() in updateCheck.ts
Collaborator
|
@dengmik-commits 发现下面的问题:
Suggested Fix if (process.platform === "win32") {
spawn(["npm", ...args].join(" "), [], {
stdio,
shell: true,
});
} else {
spawn("npm", args, {
stdio,
shell: false,
});
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
启动 deepcode 时出现 Node.js 废弃警告:
根因
child_process.spawn()在shell: true模式下不应该传入 args 数组——Node.js 只做简单拼接不转义,存在注入风险。v0.1.21 中 PR #77 修复 Windows CI 时引入了此回归:McpClient 和 updateCheck 共 3 处调用都传了 args 数组。修复
将所有
spawn(cmd, args, { shell: true })改为spawn([cmd, ...args].join(" "), [], { shell: true }),手动拼成字符串后传入。逻辑等价——cmd.exe 仍通过 PATHEXT 解析命令,不会触发 DEP0190,也不会有之前的.cmd后缀 bug。改动文件
src/mcp/mcp-client.ts:141src/updateCheck.ts:164runNpmInstallGlobal()— npm 全局安装更新包src/updateCheck.ts:208npmViewVersion()— npm view 查询最新版本updateCheck.ts的两处在启动时同时触发警告是因为它们先于 MCP 初始化运行:deepcode 启动后立即检查更新和版本信息,这两个 spawn 在npm子命令前就触发了 DEP0190。用户看到的启动警告正是来自这里。验证
启动 deepcode,不再出现 DEP0190 警告。
Closes #85