fix: injecter node_modules/.bin dans le PATH des CLIs de génération

execFileAsync ne voit pas node_modules/.bin par défaut — on l'ajoute
explicitement à l'env du process enfant pour asyncapi et redocly.
Fonctionne aussi bien en local qu'en Docker (priorité locale, fallback global).

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
z3n
2026-05-29 13:22:30 +00:00
parent 3ef7246f38
commit f27542e71f

View File

@@ -7,6 +7,13 @@ import { ApisService } from '../apis/apis.service';
const execFileAsync = promisify(execFile);
/* Ajoute node_modules/.bin au PATH pour trouver asyncapi/redocly en local */
const localBin = path.join(process.cwd(), 'node_modules', '.bin');
const execEnv = {
...process.env,
PATH: `${localBin}${path.delimiter}${process.env.PATH ?? ''}`,
};
@Injectable()
export class DocsGenerationService {
private readonly outputDir = process.env.DOCS_OUTPUT_DIR ?? './docs-output';
@@ -51,7 +58,7 @@ export class DocsGenerationService {
'--no-interactive',
'--install',
'--force-write',
], { shell: true });
], { shell: true, env: execEnv });
}
private async generateOpenApi(yamlPath: string, outputDir: string): Promise<void> {
@@ -59,6 +66,6 @@ export class DocsGenerationService {
'build-docs',
yamlPath,
'--output', path.join(outputDir, 'index.html'),
], { shell: true });
], { shell: true, env: execEnv });
}
}