Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular: Workaround for compodoc on windows machines #17334

Merged
merged 2 commits into from
Jan 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/angular/src/builders/utils/run-compodoc.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import { BuilderContext } from '@angular-devkit/architect';
import { spawn } from 'child_process';
import { Observable } from 'rxjs';
import * as path from 'path';

const hasTsConfigArg = (args: string[]) => args.indexOf('-p') !== -1;

// path.relative is necessary to workaround a compodoc issue with
// absolute paths on windows machines
const toRelativePath = (pathToTsConfig: string) => {
return path.isAbsolute(pathToTsConfig) ? path.relative('.', pathToTsConfig) : pathToTsConfig;
};

export const runCompodoc = (
{ compodocArgs, tsconfig }: { compodocArgs: string[]; tsconfig: string },
context: BuilderContext
): Observable<void> => {
return new Observable<void>((observer) => {
const tsConfigPath = toRelativePath(tsconfig);
const finalCompodocArgs = [
'compodoc',
// Default options
...(hasTsConfigArg(compodocArgs) ? [] : ['-p', tsconfig]),
...(hasTsConfigArg(compodocArgs) ? [] : ['-p', tsConfigPath]),
'-d',
`${context.workspaceRoot}`,
...compodocArgs,
Expand Down