惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Cloudflare Blog
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
博客园 - 司徒正美
V
Visual Studio Blog
G
Google Developers Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
D
Docker
Vercel News
Vercel News
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
爱范儿
爱范儿
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(scripts): support npm node command shims · openclaw/o...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -122,7 +122,7 @@ function spawnInvocation(command, commandArgs, env, platform) {

122122

if (nodeShim) {

123123

return {

124124

command: nodeShim.node,

125-

args: [nodeShim.script, ...commandArgs],

125+

args: [...nodeShim.args, ...commandArgs],

126126

};

127127

}

128128

return {

@@ -151,11 +151,39 @@ function resolveNodeCmdShim(command, platform) {

151151

if (!isExecutableFile(script, platform)) {

152152

continue;

153153

}

154-

return { node: match[1], script };

154+

return { node: match[1], args: [script] };

155+

}

156+

const npmCmdShim = resolveNpmNodeCmdShim(command, content, platform);

157+

if (npmCmdShim) {

158+

return npmCmdShim;

155159

}

156160

return null;

157161

}

158162
163+

function resolveNpmNodeCmdShim(command, content, platform) {

164+

const lines = content.split(/\r?\n/u).map((line) => line.trim());

165+

if (

166+

!lines.some((line) => /^IF EXIST "%dp0%\\node\.exe" \($/iu.test(line)) ||

167+

!lines.some((line) => /^SET "_prog=node(?:\.exe)?"$/iu.test(line))

168+

) {

169+

return null;

170+

}

171+

const invocation = lines.find((line) => line.includes('"%_prog%"') && line.endsWith("%*"));

172+

if (!invocation) {

173+

return null;

174+

}

175+

const match = /(?:^|&)\s*"%_prog%"\s+(.*?)"(%dp0%\\[^"]+)"\s+%\*$/iu.exec(invocation);

176+

if (!match || match[1].trim()) {

177+

return null;

178+

}

179+

const script = resolve(dirname(command), match[2].replace(/^%dp0%\\/iu, ""));

180+

if (!isExecutableFile(script, platform)) {

181+

return null;

182+

}

183+

const localNode = resolve(dirname(command), "node.exe");

184+

return { node: isExecutableFile(localNode, platform) ? localNode : "node", args: [script] };

185+

}

186+
159187

const cmdMetaCharactersRe = /([()\][%!^"`<>&|;, *?])/g;

160188

const jsRuntimeEntrypoints = new Set([

161189

"pnpm",

Original file line numberDiff line numberDiff line change

@@ -191,11 +191,7 @@ function writeFakeCrabbox(binDir: string, helpText: string): string {

191191

`require(${JSON.stringify(helperPath)});`,

192192

].join("\n");

193193

writeFileSync(crabboxPath, `${script}\n`, "utf8");

194-

writeFileSync(

195-

`${crabboxPath}.cmd`,

196-

`@echo off\r\n"${process.execPath}" "%~dp0crabbox" %*\r\n`,

197-

"utf8",

198-

);

194+

writeFileSync(`${crabboxPath}.cmd`, windowsNodeCmdShim("crabbox"), "utf8");

199195

chmodSync(crabboxPath, 0o755);

200196

return crabboxPath;

201197

}

@@ -212,15 +208,34 @@ function makeSlowVersionCrabbox(helpText: string): string {

212208

`else if (args[0] === "run" && args[1] === "--help") { process.stdout.write(${JSON.stringify(helpText)}); }`,

213209

].join("\n");

214210

writeFileSync(crabboxPath, `${script}\n`, "utf8");

215-

writeFileSync(

216-

`${crabboxPath}.cmd`,

217-

`@echo off\r\n"${process.execPath}" "%~dp0crabbox" %*\r\n`,

218-

"utf8",

219-

);

211+

writeFileSync(`${crabboxPath}.cmd`, windowsNodeCmdShim("crabbox"), "utf8");

220212

chmodSync(crabboxPath, 0o755);

221213

return binDir;

222214

}

223215
216+

function windowsNodeCmdShim(target: string): string {

217+

return [

218+

"@ECHO off",

219+

"GOTO start",

220+

":find_dp0",

221+

"SET dp0=%~dp0",

222+

"EXIT /b",

223+

":start",

224+

"SETLOCAL",

225+

"CALL :find_dp0",

226+

'IF EXIST "%dp0%\\node.exe" (',

227+

' SET "_prog=%dp0%\\node.exe"',

228+

") ELSE (",

229+

' SET "_prog=node"',

230+

")",

231+

"",

232+

'endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & set PATHEXT=%PATHEXT:;.JS;=;% & "%_prog%" "%dp0%\\' +

233+

target +

234+

'" %*',

235+

"",

236+

].join("\r\n");

237+

}

238+
224239

function shellSingleQuote(value: string): string {

225240

return `'${value.replaceAll("'", "'\\''")}'`;

226241

}

@@ -282,7 +297,7 @@ function makeFakeGit(

282297

"process.exit(response.status ?? 0);",

283298

].join("\n");

284299

writeFileSync(gitPath, `${script}\n`, "utf8");

285-

writeFileSync(`${gitPath}.cmd`, `@echo off\r\n"${process.execPath}" "%~dp0git" %*\r\n`, "utf8");

300+

writeFileSync(`${gitPath}.cmd`, windowsNodeCmdShim("git"), "utf8");

286301

chmodSync(gitPath, 0o755);

287302

return binDir;

288303

}