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:
@@ -7,6 +7,13 @@ import { ApisService } from '../apis/apis.service';
|
|||||||
|
|
||||||
const execFileAsync = promisify(execFile);
|
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()
|
@Injectable()
|
||||||
export class DocsGenerationService {
|
export class DocsGenerationService {
|
||||||
private readonly outputDir = process.env.DOCS_OUTPUT_DIR ?? './docs-output';
|
private readonly outputDir = process.env.DOCS_OUTPUT_DIR ?? './docs-output';
|
||||||
@@ -51,7 +58,7 @@ export class DocsGenerationService {
|
|||||||
'--no-interactive',
|
'--no-interactive',
|
||||||
'--install',
|
'--install',
|
||||||
'--force-write',
|
'--force-write',
|
||||||
], { shell: true });
|
], { shell: true, env: execEnv });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async generateOpenApi(yamlPath: string, outputDir: string): Promise<void> {
|
private async generateOpenApi(yamlPath: string, outputDir: string): Promise<void> {
|
||||||
@@ -59,6 +66,6 @@ export class DocsGenerationService {
|
|||||||
'build-docs',
|
'build-docs',
|
||||||
yamlPath,
|
yamlPath,
|
||||||
'--output', path.join(outputDir, 'index.html'),
|
'--output', path.join(outputDir, 'index.html'),
|
||||||
], { shell: true });
|
], { shell: true, env: execEnv });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user