MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / openFileCommandFor

Function openFileCommandFor

packages/server/src/lib/fileLaunch.ts:11–37  ·  view source on GitHub ↗
(
  absolutePath: string,
  line?: number,
  env: Record<string, string | undefined> = process.env,
  platform: NodeJS.Platform = process.platform,
)

Source from the content-addressed store, hash-verified

9}
10
11export function openFileCommandFor(
12 absolutePath: string,
13 line?: number,
14 env: Record<string, string | undefined> = process.env,
15 platform: NodeJS.Platform = process.platform,
16): LaunchCommand {
17 const editor = resolveEditorCommand(env);
18 if (editor !== undefined) {
19 const target = supportsLineTarget(editor) && line !== undefined
20 ? `${absolutePath}:${line}`
21 : absolutePath;
22 return {
23 command: `${editor} ${quoteShellArg(target, platform)}`,
24 args: [],
25 shell: true,
26 };
27 }
28
29 switch (platform) {
30 case 'darwin':
31 return { command: 'open', args: [absolutePath] };
32 case 'win32':
33 return { command: 'cmd', args: ['/c', 'start', '""', absolutePath] };
34 default:
35 return { command: 'xdg-open', args: [absolutePath] };
36 }
37}
38
39export function revealFileCommandFor(
40 absolutePath: string,

Callers 3

fileLaunch.test.tsFile · 0.90
handleOpenFunction · 0.90
openInMacAppFunction · 0.85

Calls 3

supportsLineTargetFunction · 0.85
resolveEditorCommandFunction · 0.70
quoteShellArgFunction · 0.70

Tested by

no test coverage detected