Skip to content

Commit

Permalink
fix: add compodoc to cachable operations #54
Browse files Browse the repository at this point in the history
fixes #54
  • Loading branch information
twittwer committed Nov 14, 2021
1 parent 6dbc1e6 commit d010072
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions packages/compodoc/src/generators/compodoc/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import {
addDependenciesToPackageJson,
formatFiles,
generateFiles,
GeneratorCallback,
getWorkspaceLayout,
joinPathFragments,
offsetFromRoot,
ProjectConfiguration,
readProjectConfiguration,
readWorkspaceConfiguration,
Tree,
updateProjectConfiguration,
updateWorkspaceConfiguration,
} from '@nrwl/devkit';
import { join } from 'path';
import { CompodocGeneratorSchema } from './schema';
Expand All @@ -19,11 +22,7 @@ export default async function runGenerator(
tree: Tree,
options: CompodocGeneratorSchema,
) {
const init = addDependenciesToPackageJson(
tree,
{},
{ '@compodoc/compodoc': '^1.1.15' },
);
const _init = init(tree);

const workspaceLayout = getWorkspaceLayout(tree);
const projectConfiguration = readProjectConfiguration(tree, options.project);
Expand All @@ -48,8 +47,42 @@ export default async function runGenerator(
}

updateProjectConfiguration(tree, options.project, projectConfiguration);

await formatFiles(tree);
return init;
return _init;
}

function init(tree: Tree): GeneratorCallback {
const install = addDependenciesToPackageJson(
tree,
{},
{ '@compodoc/compodoc': '^1.1.15' },
);

const workspaceConfiguration = readWorkspaceConfiguration(tree);
if (
workspaceConfiguration.tasksRunnerOptions?.default?.runner ===
'@nrwl/workspace/tasks-runners/default'
) {
workspaceConfiguration.tasksRunnerOptions.default.options =
workspaceConfiguration.tasksRunnerOptions.default.options || {};
workspaceConfiguration.tasksRunnerOptions.default.options.cacheableOperations =
workspaceConfiguration.tasksRunnerOptions.default.options
.cacheableOperations || [];

if (
!workspaceConfiguration.tasksRunnerOptions.default.options.cacheableOperations.includes(
'compodoc',
)
) {
workspaceConfiguration.tasksRunnerOptions.default.options.cacheableOperations.push(
'compodoc',
);
updateWorkspaceConfiguration(tree, workspaceConfiguration);
}
}

return install;
}

function determineTsconfigFile(
Expand Down

0 comments on commit d010072

Please sign in to comment.