Skip to content
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

Error when using custom updater #35

Closed
jreilly-lukava opened this issue Jul 26, 2022 · 2 comments
Closed

Error when using custom updater #35

jreilly-lukava opened this issue Jul 26, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@jreilly-lukava
Copy link

jreilly-lukava commented Jul 26, 2022

Describe the bug
I receive an error for each file processed by a custom updater.

Current behavior
The error is Cannot read properties of null (reading '1')

Expected behavior
Work without throwing error messages. It was fine with standard-version 9.5.0

Environment

  • commit-and-tag-version version(s): 10.0.1
  • Node/npm version: node 16.14.0 npm 8.5.4
  • OS: Windows 10

.versionrc.js

const glob = require('glob');
var assemblyInfoFiles = glob.sync('**/AssemblyInfo.cs', { ignore: ['**/*Test*/**', 'DBUpdater/**'] });

module.exports = {
    commitAll: true,
    preset: {
        name: 'lukavalabs'
    },
    tagPrefix: '',
    prerelease: '',
    bumpFiles: [
        ...assemblyInfoFiles.map((filename) => ({ filename, updater: './.standard-version/assembly-info.js' }))
    ],
}

assembly-info.js

const assemblyVersionRegEx = /(\d+\.\d+\.\d+)\.(\d+)/g;

module.exports.readVersion = function (contents) {
    const assemblyVersion = assemblyVersionRegEx.exec(contents);
    const oldVersion = `${assemblyVersion[1]}-${assemblyVersion[2]}`;

    return oldVersion;
}

module.exports.writeVersion = function (contents, version) {
    const newAssemblyVersion = version.split('-').join('.');

    return contents.replace(assemblyVersionRegEx, newAssemblyVersion);
}
@jreilly-lukava jreilly-lukava added the bug Something isn't working label Jul 26, 2022
@jreilly-lukava
Copy link
Author

I haven't sorted out the issue yet, but it's definitely in #11. If I undo the changes in the bump.js file everything works fine. I'll poke at it more when I have a chance.

@jreilly-lukava
Copy link
Author

Hmm, I removed the /g in my regex and things are working now. I don't understand why exactly, but I don't have time to dig into it. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant