diff --git a/scripts/run-affected.js b/scripts/run-affected.js new file mode 100755 index 0000000000..051c61f114 --- /dev/null +++ b/scripts/run-affected.js @@ -0,0 +1,29 @@ +const { execSync } = require("child_process") + +const argv = require("yargs").demandOption([ + "task", + "since", + "package-name", +]).argv + +const { task, since, packageName } = argv + +const affectedPackages = execSync( + `yarn --silent lerna ls --since=${since} --json`, + { + encoding: "utf-8", + } +) + +const packages = JSON.parse(affectedPackages) + +const isAffected = packages.some(pkg => pkg.name === packageName) + +if (isAffected) { + console.log(`${packageName} is affected. Running ${task}...`) + execSync(`yarn ${task} --scope=${packageName}`, { + stdio: "inherit", + }) +} else { + console.log(`${packageName} is not affected. Skipping ${task}...`) +}