Skip to content

Commit e32ddcc

Browse files
committed
chore(gulp): don't run pub get in parallel to avoid a race condition
1 parent 24d190c commit e32ddcc

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

gulpfile.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff 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

145152
function processToPromise(process) {

0 commit comments

Comments
 (0)