eslint-try-rules 0.1.0 → 0.1.1
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/dist/index.mjs +11 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { runLint } from "./lint.mjs";
|
|
|
3
3
|
import { generateHtml } from "./report-html.mjs";
|
|
4
4
|
import { printConsoleReport } from "./report-console.mjs";
|
|
5
5
|
import { parseRulesFile } from "./rules.mjs";
|
|
6
|
-
import { writeFileSync } from "node:fs";
|
|
6
|
+
import { realpathSync, writeFileSync } from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { performance } from "node:perf_hooks";
|
|
9
9
|
import { Command } from "commander";
|
|
@@ -34,7 +34,16 @@ const main = async () => {
|
|
|
34
34
|
console.log(`${ansis.bold.green("✔")} Report generated in ${ansis.bold(durationMs.toFixed(2))}s: ${ansis.underline(`file://${outPath}`)}`);
|
|
35
35
|
};
|
|
36
36
|
/* v8 ignore start */
|
|
37
|
-
|
|
37
|
+
const isMain = () => {
|
|
38
|
+
if (!process.argv[1]) return false;
|
|
39
|
+
try {
|
|
40
|
+
const scriptPath = realpathSync(process.argv[1]);
|
|
41
|
+
return scriptPath === import.meta.filename || scriptPath.endsWith("index.mjs");
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
if (isMain()) try {
|
|
38
47
|
await main();
|
|
39
48
|
} catch (error) {
|
|
40
49
|
if (error instanceof Error) console.error(`\n${ansis.red.bold("✖")} ${error.message}`);
|