fix: Fixed that bumping multiple files with same extension type did only update one
parent
29d941434b
commit
62453ed268
|
@ -1,5 +1,8 @@
|
||||||
name: 'Test the action'
|
name: 'Test the action'
|
||||||
on: [pull_request]
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-json:
|
test-json:
|
||||||
|
@ -502,21 +505,24 @@ jobs:
|
||||||
EXPECTED_TAG: 'v1.5.0'
|
EXPECTED_TAG: 'v1.5.0'
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.github_token }}
|
github-token: ${{ secrets.github_token }}
|
||||||
version-file: 'test-file.json, test-file.toml, test-file.yaml'
|
version-file: 'test-file.json, test-file-2.json, test-file.toml, test-file.yaml'
|
||||||
|
|
||||||
- name: Show files
|
- name: Show files
|
||||||
run: |
|
run: |
|
||||||
echo "$(<test-file.json)"
|
echo "Test json file"
|
||||||
echo ""
|
echo "$(<test-file.json)\n\n"
|
||||||
echo "$(<test-file.toml)"
|
echo "Test json 2 file"
|
||||||
echo ""
|
echo "$(<test-file-2.json)\n\n"
|
||||||
echo "$(<test-file.yaml)"
|
echo "Test toml file"
|
||||||
|
echo "$(<test-file.toml)\n\n"
|
||||||
|
echo "Test yaml file"
|
||||||
|
echo "$(<test-file.yaml)\n\n"
|
||||||
|
|
||||||
- name: Test output
|
- name: Test output
|
||||||
run: node ./test-output.js
|
run: node ./test-output.js
|
||||||
env:
|
env:
|
||||||
FILES: 'test-file.json, test-file.toml, test-file.yaml'
|
FILES: 'test-file.json, test-file-2.json, test-file.toml, test-file.yaml'
|
||||||
EXPECTED_VERSION: '1.5.0, 1.5.0, 1.11.0'
|
EXPECTED_VERSION: '1.5.0, 1.5.0, 1.5.0, 1.11.0'
|
||||||
|
|
||||||
test-config-file-path:
|
test-config-file-path:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -4,7 +4,7 @@ const gitSemverTags = require('git-semver-tags')
|
||||||
const BaseVersioning = require('./base')
|
const BaseVersioning = require('./base')
|
||||||
const bumpVersion = require('../helpers/bumpVersion')
|
const bumpVersion = require('../helpers/bumpVersion')
|
||||||
|
|
||||||
module.exports = new (class Git extends BaseVersioning {
|
module.exports = class Git extends BaseVersioning {
|
||||||
|
|
||||||
bump = (releaseType) => {
|
bump = (releaseType) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
@ -27,5 +27,4 @@ module.exports = new (class Git extends BaseVersioning {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,17 @@ const Toml = require('./toml')
|
||||||
module.exports = (fileExtension) => {
|
module.exports = (fileExtension) => {
|
||||||
switch (fileExtension.toLowerCase()) {
|
switch (fileExtension.toLowerCase()) {
|
||||||
case 'json':
|
case 'json':
|
||||||
return Json
|
return new Json()
|
||||||
|
|
||||||
case 'yaml':
|
case 'yaml':
|
||||||
case 'yml':
|
case 'yml':
|
||||||
return Yaml
|
return new Yaml()
|
||||||
|
|
||||||
case 'toml':
|
case 'toml':
|
||||||
return Toml
|
return new Toml()
|
||||||
|
|
||||||
case 'git':
|
case 'git':
|
||||||
return Git
|
return new Git()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null
|
return null
|
||||||
|
|
|
@ -4,7 +4,7 @@ const objectPath = require('object-path')
|
||||||
const BaseVersioning = require('./base')
|
const BaseVersioning = require('./base')
|
||||||
const bumpVersion = require('../helpers/bumpVersion')
|
const bumpVersion = require('../helpers/bumpVersion')
|
||||||
|
|
||||||
module.exports = new (class Json extends BaseVersioning {
|
module.exports = class Json extends BaseVersioning {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bumps the version in the package.json
|
* Bumps the version in the package.json
|
||||||
|
@ -49,5 +49,5 @@ module.exports = new (class Json extends BaseVersioning {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const toml = require('@iarna/toml')
|
||||||
const BaseVersioning = require('./base')
|
const BaseVersioning = require('./base')
|
||||||
const bumpVersion = require('../helpers/bumpVersion')
|
const bumpVersion = require('../helpers/bumpVersion')
|
||||||
|
|
||||||
module.exports = new (class Toml extends BaseVersioning {
|
module.exports = class Toml extends BaseVersioning {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bumps the version in the package.json
|
* Bumps the version in the package.json
|
||||||
|
@ -46,5 +46,5 @@ module.exports = new (class Toml extends BaseVersioning {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const yaml = require('yaml')
|
||||||
const BaseVersioning = require('./base')
|
const BaseVersioning = require('./base')
|
||||||
const bumpVersion = require('../helpers/bumpVersion')
|
const bumpVersion = require('../helpers/bumpVersion')
|
||||||
|
|
||||||
module.exports = new (class Yaml extends BaseVersioning {
|
module.exports = class Yaml extends BaseVersioning {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bumps the version in the package.json
|
* Bumps the version in the package.json
|
||||||
|
@ -53,5 +53,4 @@ module.exports = new (class Yaml extends BaseVersioning {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"name": "Test JSON file 2",
|
||||||
|
"version": "1.4.5"
|
||||||
|
}
|
|
@ -18,6 +18,8 @@ assert.ok(FILES, 'Files not defined!')
|
||||||
* Test if all the files are updated
|
* Test if all the files are updated
|
||||||
*/
|
*/
|
||||||
FILES.split(',').map((file, index) => {
|
FILES.split(',').map((file, index) => {
|
||||||
|
console.log(`Going to test file "${file}"`)
|
||||||
|
|
||||||
const fileContent = fs.readFileSync(file.trim(), 'utf8')
|
const fileContent = fs.readFileSync(file.trim(), 'utf8')
|
||||||
const fileExtension = file.split('.').pop()
|
const fileExtension = file.split('.').pop()
|
||||||
|
|
||||||
|
@ -43,8 +45,12 @@ FILES.split(',').map((file, index) => {
|
||||||
assert.fail('File extension not supported!')
|
assert.fail('File extension not supported!')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`"${file}" has a valid extension "${fileExtension.toLowerCase()}"`)
|
||||||
|
|
||||||
assert.ok(parsedContent, 'Content could not be parsed!')
|
assert.ok(parsedContent, 'Content could not be parsed!')
|
||||||
|
|
||||||
|
console.log(`"${file}" has valid content`, parsedContent)
|
||||||
|
|
||||||
const newVersionInFile = objectPath.get(parsedContent, EXPECTED_VERSION_PATH, null)
|
const newVersionInFile = objectPath.get(parsedContent, EXPECTED_VERSION_PATH, null)
|
||||||
|
|
||||||
const expectedVersions = EXPECTED_VERSION.split(',')
|
const expectedVersions = EXPECTED_VERSION.split(',')
|
||||||
|
@ -52,6 +58,8 @@ FILES.split(',').map((file, index) => {
|
||||||
? expectedVersions[index]
|
? expectedVersions[index]
|
||||||
: expectedVersions
|
: expectedVersions
|
||||||
|
|
||||||
|
console.log(`"${file}" check if "${newVersionInFile}" matches what is expected "${expectedVersion.trim()}"`)
|
||||||
|
|
||||||
assert.strictEqual(newVersionInFile, expectedVersion.trim(), 'Version does not match what is expected')
|
assert.strictEqual(newVersionInFile, expectedVersion.trim(), 'Version does not match what is expected')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue