forked from BrowserBox/BrowserBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbranch-bbx-stop.js
More file actions
executable file
·55 lines (46 loc) · 1.25 KB
/
branch-bbx-stop.js
File metadata and controls
executable file
·55 lines (46 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env node
import os from 'os';
import { spawn } from 'child_process';
import {release} from './src/hard/application.js';
console.log('Stopping BrowserBox...');
/**
* Runs the stop command for the given platform.
* @param {string} platform - The OS platform ('win32', 'linux', 'darwin', etc.)
* @returns {Promise<void>} - Resolves on success, rejects on failure
*/
function runStop(platform) {
let shell, args;
if (platform === 'win32') {
// Windows: Use PowerShell
shell = 'powershell.exe';
args = ['-Command', 'bbx stop'];
} else {
// Linux/macOS: Use Bash
shell = '/bin/bash';
args = ['-c', 'bbx stop'];
}
return new Promise((resolve, reject) => {
const child = spawn(shell, args, { stdio: 'ignore', detached: true, windowsHide: true });
child.unref();
child.on('error', () => {console.warn('Error stopping'); resolve(process.exit(1));});
});
}
/**
* Main function to stop BrowserBox.
*/
export async function stop() {
const platform = os.platform();
console.log(`Detected OS: ${platform}`);
try {
await release();
} catch(e) {
console.log('Error releasing license', e);
}
try {
// Run the stop
await runStop(platform);
} catch (error) {
process.exit(1);
}
}
//stop();