Skip to content

Commit d312f14

Browse files
perf: validate update version before backup (#5479)
* perf: validate update version before backup * perf: no need to loop through all deps Co-authored-by: Igor Randjelovic <[email protected]>
1 parent b38598d commit d312f14

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/controllers/update-controller.ts

+15
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ export class UpdateController
8888
const projectData = this.$projectDataService.getProjectData(
8989
updateOptions.projectDir
9090
);
91+
92+
try {
93+
// this is a preventive check to make sure the passed version exists before doing any backups, however
94+
// the update can still fail if the specified tag doesn't exist in one of the updatableDependencies
95+
// at this stage we only care to check a single dependency to catch invalid versions early.
96+
await this.getVersionFromTag(
97+
UpdateController.updatableDependencies[0].name,
98+
updateOptions.version
99+
);
100+
} catch (error) {
101+
this.$errors.fail(
102+
`${UpdateController.updateFailMessage} Reason is: ${error.message}`
103+
);
104+
}
105+
91106
const backupDir = path.join(
92107
updateOptions.projectDir,
93108
UpdateController.backupFolder

0 commit comments

Comments
 (0)