Skip to content

Commit

Permalink
fix keys issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jNullj committed Aug 11, 2023
1 parent d16d987 commit f702929
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
14 changes: 13 additions & 1 deletion .github/actions/docusaurus-swizzled-warning/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@ async function getChangedFilesBetweenTags(
return response.data.files.map(file => file.filename)
}

module.exports = { getAllFilesForPullRequest, getChangedFilesBetweenTags }
function findKeyEndingWith(obj, ending) {
for (const key in obj) {
if (key.endsWith(ending)) {
return key
}
}
}

module.exports = {
getAllFilesForPullRequest,
getChangedFilesBetweenTags,
findKeyEndingWith,
}
15 changes: 11 additions & 4 deletions .github/actions/docusaurus-swizzled-warning/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fetch = require('node-fetch')
const {
getAllFilesForPullRequest,
getChangedFilesBetweenTags,
findKeyEndingWith,
} = require('./helpers')

async function run() {
Expand Down Expand Up @@ -51,10 +52,16 @@ async function run() {
`https://raw.githubusercontent.com/${github.context.repo.owner}/${github.context.repo.repo}/master/${file.filename}`,
)
).json()
const oldVersion =
pkgLockOldJson.packages[`node_modules/${packageName}`].version
const newVersion =
pkgLockNewJson.packages[`node_modules/${packageName}`].version
const oldVesionModuleKey = findKeyEndingWith(
oldVersion.packages,
`node_modules/${packageName}`,
)
const newVesionModuleKey = findKeyEndingWith(
newVersion.packages,
`node_modules/${packageName}`,
)
const oldVersion = pkgLockOldJson.packages[oldVesionModuleKey].version
const newVersion = pkgLockNewJson.packages[newVesionModuleKey].version

if (newVersion !== oldVersion) {
const pkgChangedFiles = await getChangedFilesBetweenTags(
Expand Down

0 comments on commit f702929

Please sign in to comment.