in packages/monorepo/src/components/nx-project/index.ts [315:372]
synthesize() {
const projectPath = path.relative(
this.project.root.outdir,
this.project.outdir
);
const isNodeProject = NodePackageUtils.isNodeProject(this.project);
const packageManager =
NodePackageUtils.tryFindNodePackage(this.project, true)?.packageManager ||
NodePackageManager.NPM;
this.project.tasks.all
.filter((task) => {
if (
this.includedScripts.length &&
!this.includedScripts.includes(task.name)
) {
// Exclude tasks that are not in explicit "includeScripts" when defined
return false;
}
if (task.name in this.targets) {
// always include tasks that were explicitly added to nx targets
return true;
}
if (
NODE_LIFECYCLE_TASKS.includes(task.name) &&
NodePackageUtils.isNodeProject(this.project)
) {
// exclude node lifecycle tasks for node based projects
return false;
}
return true;
})
.forEach((task) => {
// Non-NodeProject don't have package.json so exec bubbles to the root.
const command = this.project.ejected
? `scripts/run-task ${task.name}`
: isNodeProject
? NodePackageUtils.command.projen(packageManager, task.name)
: NodePackageUtils.command.downloadExec(
packageManager,
"projen",
task.name
);
const _target = this.targets[task.name] || {};
_target.executor = _target.executor || "nx:run-commands";
_target.options = {
command,
cwd: projectPath,
..._target.options,
};
this.targets[task.name] = _target;
});
super.synthesize();
}