@supasayan/ytm 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +23 -15
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -47,22 +47,30 @@ async function run() {
|
|
|
47
47
|
const url = `http://127.0.0.1:${port}`;
|
|
48
48
|
console.log(`Opening browser to ${url}`);
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
// Launch default browser based on the operating system
|
|
51
|
+
let opener;
|
|
52
|
+
if (process.platform === 'darwin') {
|
|
53
|
+
opener = spawn('open', [url]);
|
|
54
|
+
} else if (process.platform === 'win32') {
|
|
55
|
+
opener = spawn('cmd', ['/c', 'start', '""', url], { shell: true });
|
|
56
|
+
} else {
|
|
57
|
+
opener = spawn('xdg-open', [url]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
opener.on('error', (err) => {
|
|
61
|
+
console.error('Failed to open browser:', err);
|
|
62
|
+
});
|
|
63
|
+
}, 1500);
|
|
56
64
|
|
|
57
|
-
// Ensure the backend process is killed when the CLI process exits
|
|
58
|
-
process.on('SIGINT', () => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
process.on('SIGTERM', () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
65
|
+
// Ensure the backend process is killed when the CLI process exits
|
|
66
|
+
process.on('SIGINT', () => {
|
|
67
|
+
server.kill('SIGINT');
|
|
68
|
+
process.exit(0);
|
|
69
|
+
});
|
|
70
|
+
process.on('SIGTERM', () => {
|
|
71
|
+
server.kill('SIGTERM');
|
|
72
|
+
process.exit(0);
|
|
73
|
+
});
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
run();
|