Skip to content

Commit 80dc9f5

Browse files
committed
feat: add open process
1 parent 47d6e29 commit 80dc9f5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

common/scripts/open.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const os = require('node:os');
2+
const { exec } = require('child_process');
3+
4+
const platform = os.platform();
5+
6+
const open = (url) => {
7+
switch (platform) {
8+
case 'darwin':
9+
exec(`open "${url}"`);
10+
break;
11+
case 'win32':
12+
exec(`start "${url}"`);
13+
break;
14+
case 'linux':
15+
exec(`xdg-open "${url}"`);
16+
default:
17+
console.log(`Unsupported platform: ${platform}`);
18+
break;
19+
}
20+
}
21+
22+
module.exports = { open }

0 commit comments

Comments
 (0)