Skip to content

Commit

Permalink
Merge pull request #17334 from storybookjs/fix-compodoc-for-windows
Browse files Browse the repository at this point in the history
Angular: Workaround for compodoc on windows machines
  • Loading branch information
shilman authored Jan 29, 2022
2 parents b4a70f0 + f7da999 commit 2c5f69c
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 2c5f69c

Please sign in to comment.