Skip to content

Commit

Permalink
Merge pull request #4886 from NativeScript/tachev/fix-migrate-exit-code
Browse files Browse the repository at this point in the history
fix: migrate and update exit with code 0 when everything is up-to-date
  • Loading branch information
Dimitar Tachev authored Jul 19, 2019
2 parents 121b065 + 2af7be5 commit fab4069
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
17 changes: 7 additions & 10 deletions lib/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
await this.$migrateController.migrate({
projectDir: this.$projectData.projectDir,
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
});
}

public async canExecute(args: string[]): Promise<boolean> {
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 NativeScript packages execute "tns update".__');
return;
}

return true;
await this.$migrateController.migrate({
projectDir: this.$projectData.projectDir,
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
});
}
}

Expand Down
10 changes: 6 additions & 4 deletions lib/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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 });
}

Expand All @@ -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 !== "";
}
}
Expand Down

0 comments on commit fab4069

Please sign in to comment.