@konvert7/klint 0.12.1 → 0.13.0
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/cli.ts +11 -2
- package/package.json +1 -1
package/cli.ts
CHANGED
|
@@ -24,6 +24,7 @@ interface CliOptions {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export async function main(opts: CliOptions = {}): Promise<void> {
|
|
27
|
+
const startedAt = performance.now();
|
|
27
28
|
const args = process.argv.slice(2);
|
|
28
29
|
|
|
29
30
|
if (args[0] === "help" || args[0] === "h") {
|
|
@@ -153,7 +154,7 @@ export async function main(opts: CliOptions = {}): Promise<void> {
|
|
|
153
154
|
unfixed > 0
|
|
154
155
|
? `klint: applied ${totalApplied} fix(es). ${unfixed} violation(s) require manual attention.`
|
|
155
156
|
: `klint: applied ${totalApplied} fix(es). No remaining violations.`;
|
|
156
|
-
process.stdout.write(
|
|
157
|
+
process.stdout.write(`${msg} Finished in ${formatDuration(startedAt)}.\n`);
|
|
157
158
|
process.exit(0);
|
|
158
159
|
}
|
|
159
160
|
|
|
@@ -161,7 +162,7 @@ export async function main(opts: CliOptions = {}): Promise<void> {
|
|
|
161
162
|
const warns = violations.filter((v) => v.severity === "warn");
|
|
162
163
|
|
|
163
164
|
if (errors.length === 0 && warns.length === 0) {
|
|
164
|
-
process.stdout.write(
|
|
165
|
+
process.stdout.write(`klint: 0 violations in ${formatDuration(startedAt)}\n`);
|
|
165
166
|
process.exit(0);
|
|
166
167
|
}
|
|
167
168
|
|
|
@@ -181,11 +182,19 @@ export async function main(opts: CliOptions = {}): Promise<void> {
|
|
|
181
182
|
process.stderr.write(
|
|
182
183
|
`klint: ${errors.length} error(s)\n\n${errors.map(formatBlock).join("\n")}`
|
|
183
184
|
);
|
|
185
|
+
process.stderr.write(`\nklint: finished in ${formatDuration(startedAt)}\n`);
|
|
184
186
|
process.exit(2);
|
|
185
187
|
}
|
|
188
|
+
process.stderr.write(`\nklint: finished in ${formatDuration(startedAt)}\n`);
|
|
186
189
|
process.exit(0);
|
|
187
190
|
}
|
|
188
191
|
|
|
192
|
+
function formatDuration(startedAt: number): string {
|
|
193
|
+
const elapsedMs = performance.now() - startedAt;
|
|
194
|
+
if (elapsedMs < 1000) return `${Math.round(elapsedMs)}ms`;
|
|
195
|
+
return `${(elapsedMs / 1000).toFixed(elapsedMs < 10_000 ? 2 : 1)}s`;
|
|
196
|
+
}
|
|
197
|
+
|
|
189
198
|
function runRustEngine({
|
|
190
199
|
configDir,
|
|
191
200
|
fix,
|
package/package.json
CHANGED