@@ -54,38 +54,48 @@ const saveBuild = async ({
5454 ) ;
5555} ;
5656
57+ const glob = async pattern =>
58+ ( await Array . fromAsync ( fs . glob ( pattern , { withFileTypes : true } ) ) )
59+ . flatMap ( dirent =>
60+ dirent . isDirectory ( )
61+ ? [ ]
62+ : npath . relative ( '.' , npath . join ( dirent . parentPath , dirent . name ) )
63+ )
64+ . sort ( ) ;
65+
5766const saveBuilds = async ( { env, manifest, onError, onResult } ) =>
5867 await Promise . all (
59- _ . map ( env . builds , async ( target , pattern ) => {
60- const paths = (
61- await Array . fromAsync ( fs . glob ( pattern , { withFileTypes : true } ) )
62- ) . flatMap ( dirent =>
63- dirent . isDirectory ( )
64- ? [ ]
65- : npath . relative ( '.' , npath . join ( dirent . parentPath , dirent . name ) )
66- ) ;
67- return await Promise . all (
68- paths . map ( async path => {
69- try {
70- const builds = flattenBuilds (
71- await getBuild ( {
72- env,
73- maxChunkSize : target . maxChunkSize ,
74- path,
75- transformers : target . transformers
76- } )
77- ) ;
78- await Promise . all (
79- _ . map ( builds , async build => {
80- await saveBuild ( { build, manifest, onError, onResult, target } ) ;
81- } )
82- ) ;
83- } catch ( error ) {
84- await onError ( { error, sourcePath : path } ) ;
85- }
86- } )
87- ) ;
88- } )
68+ _ . map (
69+ env . builds ,
70+ async ( target , pattern ) =>
71+ await Promise . all (
72+ ( await glob ( pattern ) ) . map ( async path => {
73+ try {
74+ const builds = flattenBuilds (
75+ await getBuild ( {
76+ env,
77+ maxChunkSize : target . maxChunkSize ,
78+ path,
79+ transformers : target . transformers
80+ } )
81+ ) ;
82+ await Promise . all (
83+ _ . map ( builds , async build => {
84+ await saveBuild ( {
85+ build,
86+ manifest,
87+ onError,
88+ onResult,
89+ target
90+ } ) ;
91+ } )
92+ ) ;
93+ } catch ( error ) {
94+ await onError ( { error, sourcePath : path } ) ;
95+ }
96+ } )
97+ )
98+ )
8999 ) ;
90100
91101const buildConfig = async ( { built, config, onResult, started } ) => {
0 commit comments