codesynapse 1.0.2 → 1.0.3
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 +12 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -4,6 +4,15 @@ const { spawn } = require('child_process');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
|
|
7
|
+
// Import open package dynamically to handle cases where it might not be installed
|
|
8
|
+
let open;
|
|
9
|
+
try {
|
|
10
|
+
open = require('open');
|
|
11
|
+
} catch (err) {
|
|
12
|
+
// open package not available, will skip browser opening
|
|
13
|
+
open = null;
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
const args = process.argv.slice(2);
|
|
8
17
|
const cwd = process.cwd();
|
|
9
18
|
|
|
@@ -51,13 +60,14 @@ const server = spawn('node', [serverPath], {
|
|
|
51
60
|
});
|
|
52
61
|
|
|
53
62
|
// Open browser after a short delay
|
|
54
|
-
if (openBrowser) {
|
|
63
|
+
if (openBrowser && open) {
|
|
55
64
|
setTimeout(() => {
|
|
56
|
-
const open = require('open');
|
|
57
65
|
open(`http://localhost:${port}`).catch(() => {
|
|
58
66
|
console.log('\nOpen your browser and navigate to:', `http://localhost:${port}`);
|
|
59
67
|
});
|
|
60
68
|
}, 2000);
|
|
69
|
+
} else if (openBrowser && !open) {
|
|
70
|
+
console.log('\nOpen your browser and navigate to:', `http://localhost:${port}`);
|
|
61
71
|
}
|
|
62
72
|
|
|
63
73
|
// Handle cleanup
|
package/package.json
CHANGED