Created
December 12, 2022 10:24
-
-
Save bacarybruno/5e62b1cc470dc0c1900bc4e070bcd79c to your computer and use it in GitHub Desktop.
[NX] Check if a module if affected by a change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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