bimba-cli 0.7.15 → 0.7.16

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/typecheck.js +17 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bimba-cli",
3
- "version": "0.7.15",
3
+ "version": "0.7.16",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/HeapVoid/bimba.git"
package/typecheck.js CHANGED
@@ -157,7 +157,7 @@ function send(server, seq, command, args) {
157
157
 
158
158
  export async function checkImbaTypes(entrypoint, options = {}) {
159
159
  const cwd = options.cwd || process.cwd();
160
- const timeout = Number(options.timeout || process.env.BIMBA_TYPECHECK_TIMEOUT || process.env.IMBA_TS_CHECK_TIMEOUT || 12000);
160
+ const timeout = Number(options.timeout || process.env.BIMBA_TYPECHECK_TIMEOUT || process.env.IMBA_TS_CHECK_TIMEOUT || 30000);
161
161
  const scanRoot = getScanRoot(entrypoint, cwd);
162
162
  const files = collectImbaFiles(scanRoot);
163
163
 
@@ -178,6 +178,7 @@ export async function checkImbaTypes(entrypoint, options = {}) {
178
178
  let buffer = Buffer.alloc(0);
179
179
  const seq = { value: 1 };
180
180
  const diagnostics = [];
181
+ let geterrSeq = null;
181
182
 
182
183
  const server = spawn(runner, [
183
184
  tsserver,
@@ -195,7 +196,7 @@ export async function checkImbaTypes(entrypoint, options = {}) {
195
196
  resolve(success);
196
197
  }
197
198
 
198
- const timer = setTimeout(() => {
199
+ function finishWithDiagnostics() {
199
200
  const unique = uniqueDiagnostics(diagnostics);
200
201
 
201
202
  if (!unique.length) {
@@ -207,6 +208,11 @@ export async function checkImbaTypes(entrypoint, options = {}) {
207
208
  printDiagnostics(cwd, unique);
208
209
  console.log(theme.failure(' Failure ') + ` TypeScript found ${theme.count(unique.length)} diagnostic${unique.length > 1 ? 's' : ''}`);
209
210
  finish(false);
211
+ }
212
+
213
+ const timer = setTimeout(() => {
214
+ console.log(theme.failure(' Failure ') + ` Timed out waiting for TypeScript diagnostics after ${theme.time(timeout)} ms`);
215
+ finish(false);
210
216
  }, timeout);
211
217
 
212
218
  server.on('error', (error) => {
@@ -219,7 +225,14 @@ export async function checkImbaTypes(entrypoint, options = {}) {
219
225
  server.stdout.on('data', chunk => {
220
226
  buffer = Buffer.concat([buffer, chunk]);
221
227
  buffer = parseMessages(buffer, msg => {
222
- if (msg.type != 'event' || !/Diag$/.test(msg.event)) return;
228
+ if (msg.type != 'event') return;
229
+
230
+ if (msg.event == 'requestCompleted' && msg.body?.request_seq == geterrSeq) {
231
+ finishWithDiagnostics();
232
+ return;
233
+ }
234
+
235
+ if (!/Diag$/.test(msg.event)) return;
223
236
  if (!msg.body?.diagnostics?.length) return;
224
237
 
225
238
  for (const diagnostic of msg.body.diagnostics) {
@@ -246,6 +259,7 @@ export async function checkImbaTypes(entrypoint, options = {}) {
246
259
  if (settled) return;
247
260
  send(server, seq, 'configure', { preferences: {}, hostInfo: 'bimba-typecheck' });
248
261
  for (const file of files) send(server, seq, 'open', { file, projectRootPath: cwd });
262
+ geterrSeq = seq.value;
249
263
  send(server, seq, 'geterr', { files, delay: 0 });
250
264
  }, 100);
251
265
  });