diff --git a/back/src/modules/docs-generation/docs-generation.service.ts b/back/src/modules/docs-generation/docs-generation.service.ts index 7dc5121..b5f08a4 100644 --- a/back/src/modules/docs-generation/docs-generation.service.ts +++ b/back/src/modules/docs-generation/docs-generation.service.ts @@ -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 { @@ -59,6 +66,6 @@ export class DocsGenerationService { 'build-docs', yamlPath, '--output', path.join(outputDir, 'index.html'), - ], { shell: true }); + ], { shell: true, env: execEnv }); } }