Skip to content

Commit 8336734

Browse files
committed
chore(wheelhouse): cascade template@862ffa5f
1 parent 023e62c commit 8336734

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

scripts/fleet/check/package-files-are-allowlisted.mts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,26 @@ export function checkPackage(
240240
}
241241

242242
// Undershoot: each `files:` glob must match at least one path.
243+
//
244+
// A `files:` entry naming a build-output dir (`dist` / `build`) legitimately
245+
// matches nothing in an UNBUILT checkout — `npm pack` finds no built files
246+
// because none were produced. CI's lint/check job runs without guaranteeing a
247+
// build, so don't flag a build-output entry as undershoot when that dir is
248+
// absent on disk; a populated build still gets checked. The entry's first
249+
// path segment names the dir to probe.
250+
const BUILD_OUTPUT_DIRS = new Set(['build', 'dist'])
251+
function isUnbuiltOutputEntry(entry: string): boolean {
252+
// `files:` entries are package.json globs — always forward-slash, so the
253+
// first path segment is the leading dir. No path normalization needed.
254+
const firstSeg = entry.replace(/^\.\//, '').split('/')[0]!
255+
return (
256+
BUILD_OUTPUT_DIRS.has(firstSeg) && !existsSync(path.join(pkgDir, firstSeg))
257+
)
258+
}
243259
if (Array.isArray(pkg.files)) {
244260
for (let i = 0, { length } = pkg.files; i < length; i += 1) {
245261
const entry = pkg.files[i]!
246-
if (!matchesAny(paths, entry)) {
262+
if (!matchesAny(paths, entry) && !isUnbuiltOutputEntry(entry)) {
247263
findings.push({
248264
kind: 'undershoot',
249265
pkgDir,

0 commit comments

Comments
 (0)