Skip to content

Commit 1fa8d21

Browse files
committed
Merge pull request #1836 from Microsoft/users/tihuang/portfixrelease
fix package.js on dependency download.
2 parents 929a43b + 857643e commit 1fa8d21

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

package.js

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,11 @@ function packageTask(pkgPath, commonDeps, commonSrc) {
230230
}
231231

232232
var tgtPath;
233+
var promises = [];
234+
var deferred = Q.defer();
235+
promises.push(deferred.promise);
233236

234-
validateTask(folderName, task)
237+
promises.push(validateTask(folderName, task)
235238
.then(function () {
236239
// Copy the task to the layout folder.
237240
gutil.log('Packaging: ' + task.name);
@@ -312,11 +315,18 @@ function packageTask(pkgPath, commonDeps, commonSrc) {
312315
filter(function (file) {
313316
return file.match(/(\/|\\)dependencies\.json$/);
314317
});
318+
319+
var finisheddependenciesjson = 0;
315320
if (alldependenciesjson) {
321+
if (alldependenciesjson.length == 0) {
322+
deferred.resolve();
323+
}
324+
316325
alldependenciesjson.forEach(function (dependenciesjson) {
317326
var dependencies = require(dependenciesjson);
318327
if (dependencies.archivePackages) {
319328
var archives = dependencies.archivePackages;
329+
var finishedarchiveCount = 0;
320330
archives.forEach(function (archive) {
321331
gutil.log('Download archive dependency: ' + archive.archiveName + ' from: ' + archive.url);
322332

@@ -347,26 +357,35 @@ function packageTask(pkgPath, commonDeps, commonSrc) {
347357
}
348358
})
349359

350-
gutil.log('Remove download .zip file.');
360+
gutil.log('Remove download .zip file.');
351361
shell.rm(path.join(_tempPath, archive.archiveName));
362+
finishedarchiveCount++;
363+
if (finishedarchiveCount == archives.length) {
364+
finisheddependenciesjson++;
365+
if (finisheddependenciesjson == alldependenciesjson.length) {
366+
gutil.log('Finished all dependencies download.');
367+
deferred.resolve();
368+
}
369+
}
352370
});
353371
});
354-
})
372+
});
373+
} else {
374+
deferred.resolve();
355375
}
356376
});
377+
} else {
378+
deferred.resolve();
357379
}
358-
359-
return;
360-
})
361-
.then(function () {
362-
return createStrings(task, tgtPath, dirName);
363-
})
364-
.then(function () {
365-
done();
366-
})
367-
.fail(function (err) {
368-
done(err);
369-
})
380+
}));
381+
382+
Q.all(promises).then(function () {
383+
return createStrings(task, tgtPath, dirName);
384+
}).then(function () {
385+
done();
386+
}).fail(function (err) {
387+
done(err);
388+
});
370389
});
371390
}
372391

0 commit comments

Comments
 (0)