Complete Nx plugin development toolkit: create custom generators, executors, and extend Nx workspaces with reusable automation
93
94%
Does it follow best practices?
Impact
92%
1.00xAverage score across 5 eval scenarios
Passed
No known issues
Your team built a custom Nx executor that processes documentation files, but it has performance issues and the cache never works. Developers are complaining about slow builds.
Refactor the executor to follow Nx best practices for performance and maintainability.
executor.ts:
import { readFileSync, writeFileSync } from 'fs';
export default function buildExecutor(options: any, context: any) {
console.log('Building docs...');
// All business logic inline (imagine 300 lines here)
const inputFile = readFileSync(options.inputPath, 'utf-8');
const processed = inputFile.toUpperCase(); // Processing logic
writeFileSync(options.outputPath, processed);
console.log('Build failed!');
return { success: true }; // Always returns true even on failure
}project.json target:
{
"targets": {
"build-docs": {
"executor": "../../tools/executors/docs-builder/executor",
"options": {
"inputPath": "docs/input.md",
"outputPath": "dist/docs/output.html"
}
}
}
}schema.json:
{
"type": "object",
"properties": {
"inputPath": { "type": "string" },
"outputPath": { "type": "string" }
}
}Create these files: