Skip to content

Fix platform update #823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ export class PlatformService implements IPlatformService {
let currentVersion = data && data.version ? data.version : "0.2.0";
let newVersion = version || this.$npmInstallationManager.getLatestVersion(platformData.frameworkPackageName).wait();

this.ensurePackageIsCached(platformData.frameworkPackageName, newVersion).wait();

if(platformData.platformProjectService.canUpdatePlatform(currentVersion, newVersion).wait()) {

if(!semver.valid(newVersion)) {
Expand Down Expand Up @@ -488,7 +490,6 @@ export class PlatformService implements IPlatformService {
private getFrameworkFiles(platformData: IPlatformData, version: string): IFuture<any> {
return (() => {
let cachedPackagePath = this.$npmInstallationManager.getCachedPackagePath(platformData.frameworkPackageName, version);
this.ensurePackageIsCached(cachedPackagePath, platformData.frameworkPackageName, version).wait();

let allFiles = this.$fs.enumerateFilesInDirectorySync(cachedPackagePath);
let filteredFiles = _.filter(allFiles, file => _.contains(platformData.frameworkFilesExtensions, path.extname(file)));
Expand All @@ -504,9 +505,10 @@ export class PlatformService implements IPlatformService {
}).future<any>()();
}

private ensurePackageIsCached(cachedPackagePath: string, packageName: string, version: string): IFuture<void> {
private ensurePackageIsCached(packageName: string, version: string): IFuture<void> {
return (() => {
this.$npmInstallationManager.addToCache(packageName, version).wait();
let cachedPackagePath = this.$npmInstallationManager.getCachedPackagePath(packageName, version);
if(!this.$fs.exists(path.join(cachedPackagePath, constants.PROJECT_FRAMEWORK_FOLDER_NAME)).wait()) {
// In some cases the package is not fully downloaded and the framework directory is missing
// Try removing the old package and add the real one to cache again
Expand Down