Skip to content

fix: migrate and update exit with code 0 when everything is up-to-date #4886

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 2 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
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
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