MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / openPathWithSystem

Function openPathWithSystem

desktop/system-open-path.ts:16–47  ·  view source on GitHub ↗
(targetPath: string)

Source from the content-addressed store, hash-verified

14}
15
16export async function openPathWithSystem(targetPath: string) {
17 const { command, args } = getOpenCommand()
18
19 return new Promise<boolean>((resolve) => {
20 let settled = false
21 const child = spawn(command, [...args, targetPath], {
22 stdio: 'ignore',
23 windowsHide: true,
24 })
25
26 const finish = (ok: boolean) => {
27 if (settled) {
28 return
29 }
30
31 settled = true
32 resolve(ok)
33 }
34
35 child.once('error', () => {
36 finish(false)
37 })
38 child.once('exit', (code) => {
39 finish(code === 0)
40 })
41
42 setTimeout(() => {
43 child.kill()
44 finish(false)
45 }, 10_000).unref()
46 })
47}

Callers 2

project-actions.tsFile · 0.90

Calls 4

getOpenCommandFunction · 0.85
spawnFunction · 0.85
finishFunction · 0.85
killMethod · 0.65

Tested by

no test coverage detected