@tsslint/cli 1.5.14 → 1.5.15

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/index.js +45 -25
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -9,7 +9,6 @@ const glob = require("glob");
9
9
  const fs = require("fs");
10
10
  const os = require("os");
11
11
  const languagePlugins = require("./lib/languagePlugins.js");
12
- const promises_1 = require("node:timers/promises");
13
12
  const formatting_js_1 = require("./lib/formatting.js");
14
13
  const _reset = '\x1b[0m';
15
14
  const purple = (s) => '\x1b[35m' + s + _reset;
@@ -95,9 +94,10 @@ class Project {
95
94
  const processFiles = new Set();
96
95
  const tsconfigAndLanguages = new Map();
97
96
  const formattingSettings = getFormattingSettings();
97
+ const isTTY = process.stdout.isTTY;
98
98
  let projects = [];
99
- let spinner = process.stdout.isTTY ? clack.spinner() : undefined;
100
- let lastSpinnerUpdate = Date.now();
99
+ let spinner = isTTY ? clack.spinner() : undefined;
100
+ let spinnerStopingWarn = false;
101
101
  let hasFix = false;
102
102
  let allFilesNum = 0;
103
103
  let processed = 0;
@@ -106,6 +106,16 @@ class Project {
106
106
  let errors = 0;
107
107
  let warnings = 0;
108
108
  let cached = 0;
109
+ if (isTTY) {
110
+ const write = process.stdout.write.bind(process.stdout);
111
+ process.stdout.write = (...args) => {
112
+ if (spinnerStopingWarn && typeof args[0] === 'string') {
113
+ args[0] = args[0].replace('▲', lightYellow('▲'));
114
+ }
115
+ // @ts-ignore
116
+ return write(...args);
117
+ };
118
+ }
109
119
  if (![
110
120
  '--project',
111
121
  '--projects',
@@ -269,14 +279,14 @@ class Project {
269
279
  (spinner?.stop ?? clack.log.message)(lightYellow('No input files.'));
270
280
  process.exit(1);
271
281
  }
272
- if (threads === 1) {
273
- await startWorker(worker.createLocal());
274
- }
275
- else {
282
+ if (isTTY || threads >= 2) {
276
283
  await Promise.all(new Array(threads).fill(0).map(() => {
277
284
  return startWorker(worker.create());
278
285
  }));
279
286
  }
287
+ else {
288
+ await startWorker(worker.createLocal());
289
+ }
280
290
  (spinner?.stop ?? clack.log.message)(cached
281
291
  ? darkGray(`Processed ${processed} files with cache. (Use `) + cyan(`--force`) + darkGray(` to ignore cache.)`)
282
292
  : darkGray(`Processed ${processed} files.`));
@@ -335,17 +345,12 @@ class Project {
335
345
  return;
336
346
  }
337
347
  while (project.currentFileIndex < project.fileNames.length) {
338
- const i = project.currentFileIndex++;
339
- const fileName = project.fileNames[i];
348
+ const fileName = project.fileNames[project.currentFileIndex++];
349
+ addProcessFile(fileName);
340
350
  const fileStat = fs.statSync(fileName, { throwIfNoEntry: false });
341
351
  if (!fileStat) {
342
352
  continue;
343
353
  }
344
- addProcessFile(fileName);
345
- if (spinner && Date.now() - lastSpinnerUpdate > 100) {
346
- lastSpinnerUpdate = Date.now();
347
- await (0, promises_1.setTimeout)(0);
348
- }
349
354
  let fileCache = project.cache[fileName];
350
355
  if (fileCache) {
351
356
  if (fileCache[0] !== fileStat.mtimeMs) {
@@ -393,7 +398,9 @@ class Project {
393
398
  passed++;
394
399
  }
395
400
  processed++;
396
- removeProcessFile(fileName);
401
+ removeProcessFile(fileName, project.currentFileIndex < project.fileNames.length
402
+ ? project.fileNames[project.currentFileIndex]
403
+ : undefined);
397
404
  }
398
405
  cache.saveCache(project.tsconfig, project.configFile, project.cache, ts.sys.createHash);
399
406
  await startWorker(linterWorker);
@@ -462,24 +469,37 @@ class Project {
462
469
  processFiles.add(fileName);
463
470
  updateSpinner();
464
471
  }
465
- function removeProcessFile(fileName) {
472
+ function removeProcessFile(fileName, nextFileName) {
466
473
  processFiles.delete(fileName);
467
- updateSpinner();
474
+ updateSpinner(nextFileName);
468
475
  }
469
- function updateSpinner() {
470
- if (processFiles.size === 1) {
471
- const fileName = processFiles.values().next().value;
472
- spinner?.message(darkGray(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), fileName)}`));
476
+ function updateSpinner(nextFileName) {
477
+ let msg;
478
+ if (processFiles.size === 0) {
479
+ if (nextFileName) {
480
+ msg = darkGray(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), nextFileName)}`);
481
+ }
482
+ }
483
+ else if (processFiles.size === 1) {
484
+ msg = darkGray(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), [...processFiles][0])}`);
473
485
  }
474
486
  else {
475
- spinner?.message(darkGray(`[${processed + processFiles.size}/${allFilesNum}] Processing ${processFiles.size} files`));
487
+ msg = darkGray(`[${processed + processFiles.size}/${allFilesNum}] Processing ${processFiles.size} files`);
488
+ }
489
+ if (!spinner && isTTY) {
490
+ spinner = clack.spinner();
491
+ spinner.start(msg);
492
+ }
493
+ else {
494
+ spinner?.message(msg);
476
495
  }
477
496
  }
478
497
  function log(msg, code) {
479
498
  if (spinner) {
499
+ spinnerStopingWarn = code === 2;
480
500
  spinner.stop(msg, code);
481
- spinner = clack.spinner();
482
- spinner.start();
501
+ spinnerStopingWarn = false;
502
+ spinner = undefined;
483
503
  }
484
504
  else {
485
505
  if (code === 1) {
@@ -489,7 +509,7 @@ class Project {
489
509
  clack.log.warn(msg);
490
510
  }
491
511
  else {
492
- clack.log.success(msg);
512
+ clack.log.step(msg);
493
513
  }
494
514
  }
495
515
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/cli",
3
- "version": "1.5.14",
3
+ "version": "1.5.15",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "tsslint": "./bin/tsslint.js"
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@clack/prompts": "^0.8.2",
19
- "@tsslint/config": "1.5.14",
20
- "@tsslint/core": "1.5.14",
19
+ "@tsslint/config": "1.5.15",
20
+ "@tsslint/core": "1.5.15",
21
21
  "@volar/language-core": "~2.4.0",
22
22
  "@volar/typescript": "~2.4.0",
23
23
  "glob": "^10.4.1",
@@ -30,5 +30,5 @@
30
30
  "@vue-vine/language-service": "latest",
31
31
  "@vue/language-core": "latest"
32
32
  },
33
- "gitHead": "18423eb07acca1f6f016275700ba589c773725a5"
33
+ "gitHead": "4aac5cac25ff3f0bb67ddbe2cfe56bde30a7f6b9"
34
34
  }