pyproject-updater.js 554 B

1234567891011121314151617181920
  1. /**
  2. * Custom updater for pyproject.toml
  3. * Used by standard-version to bump version in pyproject.toml
  4. */
  5. const stringifyPackage = require('stringify-package');
  6. const detectIndent = require('detect-indent');
  7. const detectNewline = require('detect-newline');
  8. module.exports.readVersion = function (contents) {
  9. const match = contents.match(/^version = "(.*)"$/m);
  10. return match ? match[1] : null;
  11. };
  12. module.exports.writeVersion = function (contents, version) {
  13. return contents.replace(
  14. /^version = ".*"$/m,
  15. `version = "${version}"`
  16. );
  17. };