feat(yml): Added support for no quotes and double quotes
parent
b985fd640a
commit
2a80eb3e4a
|
@ -1,3 +1,4 @@
|
|||
const core = require('@actions/core')
|
||||
const objectPath = require('object-path')
|
||||
const yaml = require('yaml')
|
||||
|
||||
|
@ -29,11 +30,20 @@ module.exports = new (class Yaml extends BaseVersioning {
|
|||
// Get the name of where the version is in
|
||||
const versionName = this.versionPath.split('.').pop()
|
||||
|
||||
core.info(`Bumped file "${this.fileLocation}" from "${oldVersion}" to "${this.newVersion}"`)
|
||||
|
||||
this.update(
|
||||
// We use replace instead of yaml.stringify so we can preserve white spaces and comments
|
||||
// Replace if version was used with single quotes
|
||||
fileContent.replace(
|
||||
`${versionName}: '${oldVersion}'`,
|
||||
`${versionName}: '${this.newVersion}'`,
|
||||
).replace( // Replace if version was used with double quotes
|
||||
`${versionName}: "${oldVersion}"`,
|
||||
`${versionName}: "${this.newVersion}"`,
|
||||
).replace( // Replace if version was used with no quotes
|
||||
`${versionName}: ${oldVersion}`,
|
||||
`${versionName}: ${this.newVersion}`,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
version: '1.10.50'
|
||||
|
||||
package:
|
||||
version: '9.4.5'
|
||||
no-quotes-version: 9.5.50
|
||||
double-quotes-version: "9.6.33"
|
||||
|
||||
# Comment
|
||||
different:
|
||||
|
|
Loading…
Reference in New Issue