From 5085b783a4a8ff311a9187255fe39dc8e7d77fee Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Fri, 19 Jul 2019 14:44:37 +0300 Subject: [PATCH 1/2] fix: migrate and update exit with code 0 when everything is up-to-date --- lib/commands/migrate.ts | 17 +++++++---------- lib/commands/update.ts | 10 ++++++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib/commands/migrate.ts b/lib/commands/migrate.ts index e40cfd8651..9442c2d200 100644 --- a/lib/commands/migrate.ts +++ b/lib/commands/migrate.ts @@ -5,28 +5,25 @@ export class MigrateCommand implements ICommand { private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $migrateController: IMigrateController, private $projectData: IProjectData, - private $errors: IErrors) { + private $logger: ILogger) { this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { - await this.$migrateController.migrate({ - projectDir: this.$projectData.projectDir, - platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS] - }); - } - - public async canExecute(args: string[]): Promise { const shouldMigrateResult = await this.$migrateController.shouldMigrate({ projectDir: this.$projectData.projectDir, platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS] }); if (!shouldMigrateResult) { - this.$errors.failWithoutHelp('Project is compatible with NativeScript "v6.0.0". To get the latest NativesScript packages execute "tns update".'); + this.$logger.printMarkdown('__Project is compatible with NativeScript "v6.0.0". To get the latest NativesScript packages execute "tns update".__'); + return; } - return true; + await this.$migrateController.migrate({ + projectDir: this.$projectData.projectDir, + platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS] + }); } } diff --git a/lib/commands/update.ts b/lib/commands/update.ts index 0dddf6a07f..28b8ee1302 100644 --- a/lib/commands/update.ts +++ b/lib/commands/update.ts @@ -9,11 +9,17 @@ export class UpdateCommand implements ICommand { private $migrateController: IMigrateController, private $options: IOptions, private $errors: IErrors, + private $logger: ILogger, private $projectData: IProjectData) { this.$projectData.initializeProjectData(); } public async execute(args: string[]): Promise { + if (!await this.$updateController.shouldUpdate({ projectDir: this.$projectData.projectDir, version: args[0] })) { + this.$logger.printMarkdown(`__${UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE}__`); + return; + } + await this.$updateController.update({ projectDir: this.$projectData.projectDir, version: args[0], frameworkPath: this.$options.frameworkPath }); } @@ -27,10 +33,6 @@ export class UpdateCommand implements ICommand { this.$errors.failWithoutHelp(UpdateCommand.SHOULD_MIGRATE_PROJECT_MESSAGE); } - if (!await this.$updateController.shouldUpdate({ projectDir: this.$projectData.projectDir, version: args[0] })) { - this.$errors.failWithoutHelp(UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE); - } - return args.length < 2 && this.$projectData.projectDir !== ""; } } From 2af7be58e37a14782ace9ce151e945a3daf65809 Mon Sep 17 00:00:00 2001 From: Dimitar Tachev Date: Fri, 19 Jul 2019 14:56:03 +0300 Subject: [PATCH 2/2] chore: fix pr comments --- lib/commands/migrate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/migrate.ts b/lib/commands/migrate.ts index 9442c2d200..9f22b42972 100644 --- a/lib/commands/migrate.ts +++ b/lib/commands/migrate.ts @@ -16,7 +16,7 @@ export class MigrateCommand implements ICommand { }); if (!shouldMigrateResult) { - this.$logger.printMarkdown('__Project is compatible with NativeScript "v6.0.0". To get the latest NativesScript packages execute "tns update".__'); + this.$logger.printMarkdown('__Project is compatible with NativeScript "v6.0.0". To get the latest NativeScript packages execute "tns update".__'); return; }