Skip to content

Instantly share code, notes, and snippets.

@bacarybruno
Created December 12, 2022 10:24
Show Gist options
  • Save bacarybruno/5e62b1cc470dc0c1900bc4e070bcd79c to your computer and use it in GitHub Desktop.
Save bacarybruno/5e62b1cc470dc0c1900bc4e070bcd79c to your computer and use it in GitHub Desktop.
[NX] Check if a module if affected by a change
const { execSync } = require('child_process')
const checkIfAffected = (modules) => {
const result = execSync('yarn nx print-affected --select=projects').toString()
const changedModules = result.split('\n')[2].split(', ')
return modules.some((module) => changedModules.includes(module))
}
if (require.main === module) {
const modules = process.argv.slice(2)
const isAffected = checkIfAffected(modules)
process.exit(isAffected ? 0 : 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment