Add run-affected script
This commit is contained in:
parent
dd70f0b72b
commit
e14c569aa4
|
@ -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}...`)
|
||||||
|
}
|
Loading…
Reference in New Issue