MCPcopy
hub / github.com/midrender/revideo / openInExplorer

Function openInExplorer

packages/vite-plugin/src/openInExplorer.ts:4–31  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

2import {platform} from 'os';
3
4export function openInExplorer(file: string) {
5 let command: string | null = null;
6 let args = [file];
7 const os = platform();
8
9 switch (os) {
10 case 'win32':
11 command = 'explorer';
12 break;
13 case 'linux':
14 if (isRunningOnWSL()) {
15 command = 'bash';
16 args = ['-c', `cd ${file} && explorer.exe .`];
17 } else {
18 command = 'xdg-open';
19 }
20 break;
21 case 'darwin':
22 command = 'open';
23 break;
24 }
25
26 if (command) {
27 spawn(command, args, {detached: true}).unref();
28 } else {
29 console.warn(`Unsupported OS: ${os}`);
30 }
31}
32
33function isRunningOnWSL(): boolean {
34 try {

Callers 1

configureServerFunction · 0.90

Calls 3

isRunningOnWSLFunction · 0.85
spawnFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected