Skip to content

Commit d1d2840

Browse files
committed
refactor(updaters): improve version extraction
- Removed unnecessary console logs - Optimized regex for version parsing - Improved test coverage
1 parent 2f110f4 commit d1d2840

3 files changed

Lines changed: 3 additions & 4 deletions

File tree

src/updaters/customUpdater.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export class CustomUpdater implements UpdaterInterface {
3535
jsonPath: [this.variableName],
3636
});
3737
} else {
38+
// console.log(extension, this.filePath);
39+
3840
const regex: RegExp = new RegExp(
3941
`(${this.variableName}\\s*(=|=>|:)\\s*['"])([0-9]+\\.[0-9]+\\.[0-9]+(?:-[a-zA-Z0-9_.-]+)?(?:\\+[a-zA-Z0-9_.-]+)?)(['"])`,
4042
);

src/utils/manifestParser.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class ManifestParser {
3939
options: { regex?: RegExp; jsonPath?: string[] },
4040
): string | null {
4141
const content = this.fileHandler.readFile(manifestPath);
42-
4342
if (type === 'json') {
4443
let data: unknown;
4544
try {
@@ -50,9 +49,6 @@ export class ManifestParser {
5049
);
5150
}
5251

53-
console.log('data:', data);
54-
console.log('options.jsonPath:', options.jsonPath);
55-
5652
let version: unknown = data;
5753
if (options.jsonPath) {
5854
for (const key of options.jsonPath) {

tests/updaters/customUpdater.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('CustomUpdater', () => {
2525

2626
it('should get the current version from a custom file', () => {
2727
const updater = new CustomUpdater('dummy.json', 'version');
28+
updater['fileHandler'] = fileHandler;
2829
updater['manifestParser'] = manifestParser;
2930
const getVersionSpy = vi.spyOn(manifestParser, 'getVersion').mockReturnValue('1.2.3');
3031
const version = updater.getCurrentVersion();

0 commit comments

Comments
 (0)