@@ -3,12 +3,17 @@ import pathlib from 'path';
33import * as core from '@actions/core' ;
44import { getExecOutput } from '@actions/exec' ;
55
6+ interface PackageRecord {
7+ directory : string
8+ name : string
9+ }
10+
611/**
712 * Recursively locates the packages present in a directory, up to an optional max depth
813 */
914async function findPackages ( directory : string , maxDepth ?: number ) {
10- const output : string [ ] = [ ] ;
11- async function * recurser ( currentDir : string , currentDepth : number ) : AsyncGenerator < string > {
15+ const output : PackageRecord [ ] = [ ] ;
16+ async function * recurser ( currentDir : string , currentDepth : number ) : AsyncGenerator < PackageRecord > {
1217 if ( maxDepth !== undefined && currentDepth >= maxDepth ) return ;
1318
1419 const items = await fs . readdir ( currentDir , { withFileTypes : true } ) ;
@@ -18,7 +23,10 @@ async function findPackages(directory: string, maxDepth?: number) {
1823 if ( item . name === 'package.json' ) {
1924 try {
2025 const { default : { name } } = await import ( fullPath , { with : { type : 'json' } } ) ;
21- if ( name ) yield name ;
26+ if ( name ) {
27+ yield { name, directory } ;
28+ return ;
29+ } ;
2230 } catch { }
2331 }
2432 continue ;
@@ -66,7 +74,7 @@ async function main() {
6674 const packages = await findPackages ( dirPath ) ;
6775 core . setOutput ( packageType , packages ) ;
6876 core . summary . addHeading ( `Found ${ packageType } ` ) ;
69- core . summary . addList ( packages ) ;
77+ core . summary . addList ( packages . map ( ( { name } ) => name ) ) ;
7078 core . summary . write ( ) ;
7179}
7280
0 commit comments