Files
zgene 6bed393c12
Backend Tests / backend-unit-test (push) Has been cancelled
Backend Tests / benchmark-test (push) Has been cancelled
CI@main / Node.js v22 (ubuntu-latest) (push) Has been cancelled
Thrift Syntax Validation / validate-thrift (push) Has been cancelled
License Check / License Check (push) Has been cancelled
first commit
2026-05-14 13:29:56 +08:00

38 lines
1.1 KiB
JavaScript

const { RushConfiguration } = require('@rushstack/rush-sdk')
const getRushConfiguration = (function () {
let rushConfiguration = null
return function () {
// eslint-disable-next-line
return (rushConfiguration ||= RushConfiguration.loadFromDefaultLocation({
startingFolder: process.cwd(),
}))
}
})()
function getChangedPackages(changedFiles) {
const changedPackages = new Set()
try {
const rushConfiguration = getRushConfiguration()
const { rushJsonFolder } = rushConfiguration
const lookup = rushConfiguration.getProjectLookupForRoot(rushJsonFolder)
for (const file of changedFiles) {
const project = lookup.findChildPath(file)
// If the registered package information is not found, it is considered a generic file change
const packageName = project?.packageName || 'misc'
if (!changedPackages.has(packageName)) {
changedPackages.add(packageName)
}
}
} catch (e) {
console.error(e)
throw e
}
return changedPackages
}
exports.getChangedPackages = getChangedPackages
exports.getRushConfiguration = getRushConfiguration