Skip to content

Commit 979321d

Browse files
committed
fix: check the version of nativescript-unit-test-runner from shouldMigrate action
Currently the version of nativescript-unit-test-runner is not checked on shouldMigrate action and this led to the behavior that shouldMigrate returns true for all projects that have `nativescript-unit-test-runner` as dependency.
1 parent b7fb5e4 commit 979321d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/controllers/migrate-controller.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ for more information, refer to the instructions in the following blog post: <lin
7575
{ packageName: "nativescript-cardview", verifiedVersion: "3.2.0" },
7676
{
7777
packageName: "nativescript-unit-test-runner", verifiedVersion: "0.6.4",
78-
shouldMigrateAction: (projectData: IProjectData) => this.hasDependency({ packageName: "nativescript-unit-test-runner", isDev: false }, projectData),
78+
shouldMigrateAction: async (projectData: IProjectData) => {
79+
const dependency = { packageName: "nativescript-unit-test-runner", verifiedVersion: "0.6.4", isDev: false };
80+
const result = this.hasDependency(dependency, projectData) && await this.shouldMigrateDependencyVersion(dependency, projectData);
81+
return result;
82+
},
7983
migrateAction: this.migrateUnitTestRunner.bind(this)
8084
},
8185
{ packageName: MigrateController.typescriptPackageName, isDev: true, getVerifiedVersion: this.getAngularTypeScriptVersion.bind(this) },
@@ -133,7 +137,7 @@ for more information, refer to the instructions in the following blog post: <lin
133137
const dependency = this.migrationDependencies[i];
134138
const hasDependency = this.hasDependency(dependency, projectData);
135139

136-
if (hasDependency && dependency.shouldMigrateAction && dependency.shouldMigrateAction(projectData)) {
140+
if (hasDependency && dependency.shouldMigrateAction && await dependency.shouldMigrateAction(projectData)) {
137141
return true;
138142
}
139143

@@ -273,7 +277,7 @@ for more information, refer to the instructions in the following blog post: <lin
273277
const dependency = this.migrationDependencies[i];
274278
const hasDependency = this.hasDependency(dependency, projectData);
275279

276-
if (hasDependency && dependency.migrateAction && dependency.shouldMigrateAction(projectData)) {
280+
if (hasDependency && dependency.migrateAction && await dependency.shouldMigrateAction(projectData)) {
277281
const newDependencies = await dependency.migrateAction(projectData, path.join(projectData.projectDir, MigrateController.backupFolder));
278282
for (const newDependency of newDependencies) {
279283
await this.migrateDependency(newDependency, projectData);

lib/definitions/migrate.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ interface IMigrationDependency extends IDependency {
1616
verifiedVersion?: string;
1717
getVerifiedVersion?: (projectData: IProjectData) => Promise<string>;
1818
shouldAddIfMissing?: boolean;
19-
shouldMigrateAction?: (projectData: IProjectData) => boolean;
19+
shouldMigrateAction?: (projectData: IProjectData) => Promise<boolean>;
2020
migrateAction?: (projectData: IProjectData, migrationBackupDirPath: string) => Promise<IMigrationDependency[]>;
2121
}

0 commit comments

Comments
 (0)