File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed
Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -129,17 +129,24 @@ gulp.task('modules/build.dart/pubspec', function() {
129129 done ( ) ;
130130 } ) )
131131 . pipe ( gulp . dest ( outputDir ) ) ;
132- // We need to wait for all pubspecs to be present before executing
132+ // 1. We need to wait for all pubspecs to be present before executing
133133 // `pub get` as it checks the folders of the dependencies!
134- return streamToPromise ( changedStream )
135- . then ( function ( ) {
136- return Q . all ( files . map ( function ( file ) {
137- return processToPromise ( spawn ( DART_SDK . PUB , [ 'get' ] , {
138- stdio : 'inherit' ,
139- cwd : path . dirname ( file )
140- } ) ) ;
141- } ) ) ;
142- } ) ;
134+ // 2. We execute `pub get` commands sequentially to avoid race condition with pub cache
135+ var promise = streamToPromise ( changedStream ) . then ( function ( ) {
136+ for ( var i = 0 ; i < files . length ; i ++ ) {
137+ ( function ( file ) {
138+ promise = promise . then ( function ( ) {
139+ return processToPromise ( spawn ( DART_SDK . PUB , [ 'get' ] , {
140+ stdio : 'inherit' ,
141+ cwd : path . dirname ( file )
142+ } ) ) ;
143+ } ) ;
144+ } ) ( files [ i ] ) ;
145+ }
146+ } ) ;
147+
148+ return promise ;
149+
143150} ) ;
144151
145152function processToPromise ( process ) {
You can’t perform that action at this time.
0 commit comments