any-doctor 0.0.3 → 0.0.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/bin/cli.js +11 -2
- package/bin/discover.js +8 -3
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { runDiff } from "./diff.js";
|
|
|
10
10
|
import { deriveSummary } from "./summary.js";
|
|
11
11
|
import { copyToClipboard } from "./clipboard.js";
|
|
12
12
|
import { runDashboard } from "./dashboard.js";
|
|
13
|
-
import { brokenDoctors, discoverDoctors, globalDoctorsDir, unsafeSlugs, scopeLabel } from "./discover.js";
|
|
13
|
+
import { brokenDoctors, discoverDoctors, globalDoctorsDir, resolveDoctorPath, unsafeSlugs, scopeLabel } from "./discover.js";
|
|
14
14
|
import { causeSummaryLine, describeRunnerError, isRunnerError, verifyDoctor } from "./runner.js";
|
|
15
15
|
import { scanDoctorFile, capabilitySummary } from "./capabilities.js";
|
|
16
16
|
import { selectDoctor } from "./select.js";
|
|
@@ -105,6 +105,15 @@ function selectionOutcome(sel) {
|
|
|
105
105
|
return { exit: 0 };
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
// An extensionless bare token is a doctor slug ONLY when it resolves in a
|
|
109
|
+
// scope (repo, global, bundled) - never merely because it looks like one,
|
|
110
|
+
// so `run src` still means the target directory unless a doctors/src.mjs
|
|
111
|
+
// exists somewhere. Scope precedence is resolveDoctorPath's law.
|
|
112
|
+
function isBareDoctorSlug(arg) {
|
|
113
|
+
if (path.basename(arg) !== arg || path.isAbsolute(arg))
|
|
114
|
+
return false;
|
|
115
|
+
return resolveDoctorPath(arg, process.cwd()) !== null;
|
|
116
|
+
}
|
|
108
117
|
function parseArgs(args) {
|
|
109
118
|
const out = { targetDir: path.resolve("."), all: false, global: false, includeTests: false, format: "report", failOn: "none" };
|
|
110
119
|
let targetDirSet = false;
|
|
@@ -134,7 +143,7 @@ function parseArgs(args) {
|
|
|
134
143
|
i += 1;
|
|
135
144
|
}
|
|
136
145
|
}
|
|
137
|
-
else if (out.doctorPath === undefined && DOCTOR_FILE_RE.test(a))
|
|
146
|
+
else if (out.doctorPath === undefined && (DOCTOR_FILE_RE.test(a) || isBareDoctorSlug(a)))
|
|
138
147
|
out.doctorPath = a;
|
|
139
148
|
else if (!targetDirSet) {
|
|
140
149
|
out.targetDir = path.resolve(a);
|
package/bin/discover.js
CHANGED
|
@@ -100,10 +100,15 @@ export function resolveDoctorPath(arg, cwd, opts) {
|
|
|
100
100
|
(_a = opts === null || opts === void 0 ? void 0 : opts.globalDir) !== null && _a !== void 0 ? _a : globalDoctorsDir(),
|
|
101
101
|
(_b = opts === null || opts === void 0 ? void 0 : opts.bundledDir) !== null && _b !== void 0 ? _b : bundledDoctorsDir(),
|
|
102
102
|
].filter((d) => Boolean(d));
|
|
103
|
+
// A bare slug names the doctor, not the file: try it verbatim (for
|
|
104
|
+
// callers who typed the extension) and then the doctor extensions,
|
|
105
|
+
// canonical .mjs first.
|
|
103
106
|
for (const dir of scopes) {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
for (const suffix of ["", ".mjs", ".cjs", ".js"]) {
|
|
108
|
+
const candidate = path.join(dir, base + suffix);
|
|
109
|
+
if (fs.existsSync(candidate))
|
|
110
|
+
return candidate;
|
|
111
|
+
}
|
|
107
112
|
}
|
|
108
113
|
const direct = path.resolve(cwd, arg);
|
|
109
114
|
if (fs.existsSync(direct))
|