File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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,
You can’t perform that action at this time.
0 commit comments