Skip to content

Commit fab4069

Browse files
author
Dimitar Tachev
authored
Merge pull request #4886 from NativeScript/tachev/fix-migrate-exit-code
fix: migrate and update exit with code 0 when everything is up-to-date
2 parents 121b065 + 2af7be5 commit fab4069

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

lib/commands/migrate.ts

+7-10
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,25 @@ export class MigrateCommand implements ICommand {
55
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
66
private $migrateController: IMigrateController,
77
private $projectData: IProjectData,
8-
private $errors: IErrors) {
8+
private $logger: ILogger) {
99
this.$projectData.initializeProjectData();
1010
}
1111

1212
public async execute(args: string[]): Promise<void> {
13-
await this.$migrateController.migrate({
14-
projectDir: this.$projectData.projectDir,
15-
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
16-
});
17-
}
18-
19-
public async canExecute(args: string[]): Promise<boolean> {
2013
const shouldMigrateResult = await this.$migrateController.shouldMigrate({
2114
projectDir: this.$projectData.projectDir,
2215
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
2316
});
2417

2518
if (!shouldMigrateResult) {
26-
this.$errors.failWithoutHelp('Project is compatible with NativeScript "v6.0.0". To get the latest NativesScript packages execute "tns update".');
19+
this.$logger.printMarkdown('__Project is compatible with NativeScript "v6.0.0". To get the latest NativeScript packages execute "tns update".__');
20+
return;
2721
}
2822

29-
return true;
23+
await this.$migrateController.migrate({
24+
projectDir: this.$projectData.projectDir,
25+
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
26+
});
3027
}
3128
}
3229

lib/commands/update.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ export class UpdateCommand implements ICommand {
99
private $migrateController: IMigrateController,
1010
private $options: IOptions,
1111
private $errors: IErrors,
12+
private $logger: ILogger,
1213
private $projectData: IProjectData) {
1314
this.$projectData.initializeProjectData();
1415
}
1516

1617
public async execute(args: string[]): Promise<void> {
18+
if (!await this.$updateController.shouldUpdate({ projectDir: this.$projectData.projectDir, version: args[0] })) {
19+
this.$logger.printMarkdown(`__${UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE}__`);
20+
return;
21+
}
22+
1723
await this.$updateController.update({ projectDir: this.$projectData.projectDir, version: args[0], frameworkPath: this.$options.frameworkPath });
1824
}
1925

@@ -27,10 +33,6 @@ export class UpdateCommand implements ICommand {
2733
this.$errors.failWithoutHelp(UpdateCommand.SHOULD_MIGRATE_PROJECT_MESSAGE);
2834
}
2935

30-
if (!await this.$updateController.shouldUpdate({ projectDir: this.$projectData.projectDir, version: args[0] })) {
31-
this.$errors.failWithoutHelp(UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE);
32-
}
33-
3436
return args.length < 2 && this.$projectData.projectDir !== "";
3537
}
3638
}

0 commit comments

Comments
 (0)