Skip to content

Commit

Permalink
feat(Java): add support for pom.xml files for Java Maven projects
Browse files Browse the repository at this point in the history
  • Loading branch information
dwmkerr committed May 15, 2020
1 parent c5130a2 commit 7e85e22
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/updaters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function getUpdaterByFilename (filename) {
if (PLAIN_TEXT_BUMP_FILES.includes(filename)) {
return getUpdaterByType('plain-text')
}
if (/pom.xml$/.test(filename)) {
return getUpdaterByType('pom')
}
throw Error(
`Unsupported file (${filename}) provided for bumping.\n Please specifcy the updater \`type\` or use a custom \`updater\`.`
)
Expand Down Expand Up @@ -52,7 +55,13 @@ module.exports.resolveUpdaterObjectFromArgument = function (arg) {
* We weren't able to resolve an updater for the argument.
*/
if (!updater.updater) {
return false
/* Previously we just returned 'false' for this function, but that causes
an error immediately afterwards as we try to read the result as an object
with a field 'filename'. So better to bail here, it means something is
wrong, most likely someone has goofed making an updater. */
throw Error(
`Failed to create an updater for ${JSON.stringify(arg)}\n Please specifcy the updater \`type\` or use a custom \`updater\`.`
)
}

return updater
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"posttest": "eslint .",
"test": "nyc mocha --timeout=30000 test.js",
"test:debug": "mocha --inspect-brk --timeout=30000 test.js",
"release": "bin/cli.js"
},
"nyc": {
Expand Down
24 changes: 24 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,30 @@ describe('standard-version', function () {
})
})

it('reads and writes to Java Maven `pom.xml` file', function () {
fs.copyFileSync('../test/mocks/pom-6.3.1.xml', 'pom.xml')
commit('feat: yet another commit')
return require('./index')({
silent: true,
packageFiles: [
{
filename: 'pom.xml',
type: 'pom'
}
],
bumpFiles: [
{
filename: 'pom.xml',
type: 'pom'
}
]
})
.then(() => {
const expected = fs.readFileSync('../test/mocks/pom-6.4.0.xml', 'utf-8')
fs.readFileSync('pom.xml', 'utf-8').should.equal(expected)
})
})

describe('npm-shrinkwrap.json support', function () {
beforeEach(function () {
writeNpmShrinkwrapJson('1.0.0')
Expand Down

0 comments on commit 7e85e22

Please sign in to comment.