Skip to content

Commit 48a115f

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #823 from NativeScript/fatme/fix-update-platform
Fix platform update
2 parents 77746fe + 24c4301 commit 48a115f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/services/platform-service.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ export class PlatformService implements IPlatformService {
414414
let currentVersion = data && data.version ? data.version : "0.2.0";
415415
let newVersion = version || this.$npmInstallationManager.getLatestVersion(platformData.frameworkPackageName).wait();
416416

417+
this.ensurePackageIsCached(platformData.frameworkPackageName, newVersion).wait();
418+
417419
if(platformData.platformProjectService.canUpdatePlatform(currentVersion, newVersion).wait()) {
418420

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

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

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

0 commit comments

Comments
 (0)