idea-manager 0.9.3 → 0.9.4
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/package.json +1 -1
- package/src/cli.ts +23 -5
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -130,11 +130,29 @@ program
|
|
|
130
130
|
process.exit(1);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
// Wait for server to be ready, then open browser
|
|
134
|
+
const waitAndOpen = async () => {
|
|
135
|
+
const url = `http://localhost:${port}`;
|
|
136
|
+
for (let i = 0; i < 30; i++) {
|
|
137
|
+
try {
|
|
138
|
+
await new Promise<void>((resolve, reject) => {
|
|
139
|
+
const http = require('http');
|
|
140
|
+
const req = http.get(url, (res: { statusCode: number }) => {
|
|
141
|
+
if (res.statusCode === 200) resolve();
|
|
142
|
+
else reject();
|
|
143
|
+
});
|
|
144
|
+
req.on('error', reject);
|
|
145
|
+
req.setTimeout(1000, () => { req.destroy(); reject(); });
|
|
146
|
+
});
|
|
147
|
+
// Server is ready
|
|
148
|
+
await openAsApp(url);
|
|
149
|
+
return;
|
|
150
|
+
} catch {
|
|
151
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
waitAndOpen().catch(() => {});
|
|
138
156
|
|
|
139
157
|
process.on('SIGINT', () => { child.kill(); process.exit(0); });
|
|
140
158
|
process.on('SIGTERM', () => { child.kill(); process.exit(0); });
|