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 objectPath = require('object-path')
|
||||||
const yaml = require('yaml')
|
const yaml = require('yaml')
|
||||||
|
|
||||||
|
@ -29,11 +30,20 @@ module.exports = new (class Yaml extends BaseVersioning {
|
||||||
// Get the name of where the version is in
|
// Get the name of where the version is in
|
||||||
const versionName = this.versionPath.split('.').pop()
|
const versionName = this.versionPath.split('.').pop()
|
||||||
|
|
||||||
|
core.info(`Bumped file "${this.fileLocation}" from "${oldVersion}" to "${this.newVersion}"`)
|
||||||
|
|
||||||
this.update(
|
this.update(
|
||||||
// We use replace instead of yaml.stringify so we can preserve white spaces and comments
|
// 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(
|
fileContent.replace(
|
||||||
`${versionName}: '${oldVersion}'`,
|
`${versionName}: '${oldVersion}'`,
|
||||||
`${versionName}: '${this.newVersion}'`,
|
`${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 {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
|
version: '1.10.50'
|
||||||
|
|
||||||
package:
|
package:
|
||||||
version: '9.4.5'
|
version: '9.4.5'
|
||||||
|
no-quotes-version: 9.5.50
|
||||||
|
double-quotes-version: "9.6.33"
|
||||||
|
|
||||||
# Comment
|
# Comment
|
||||||
different:
|
different:
|
||||||
|
|
Loading…
Reference in New Issue