Skip to content

Commit

Permalink
Merge pull request #53 from twittwer/workspace-watch
Browse files Browse the repository at this point in the history
  • Loading branch information
twittwer authored Oct 31, 2021
2 parents ef14f13 + a87844e commit b0d25c4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/compodoc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/s



# [1.6.0](https://github.com/twittwer/nx-tools/compare/compodoc/v1.5.3...compodoc/v1.6.0) (2021-10-31)
## [1.6.0](https://github.com/twittwer/nx-tools/compare/compodoc/v1.5.3...compodoc/v1.6.0) (2021-10-31)


### Bug Fixes
Expand Down
40 changes: 31 additions & 9 deletions packages/compodoc/src/executors/build/executor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BuildExecutorSchema, CompodocOptions } from './schema';
import { spawn } from 'child_process';
import { ChildProcess, spawn } from 'child_process';
import { join, relative, resolve, sep } from 'path';
import {
ExecutorContext,
Expand Down Expand Up @@ -37,14 +37,36 @@ export default async function runExecutor(
}

return new Promise<{ success: boolean }>((resolve) => {
options.debug &&
console.log('Spawn Compodoc...', {
command: cmd,
arguments: cmdArgs,
options: cmdOpts,
});

const childProcess = spawn(cmd, cmdArgs, cmdOpts);
let childProcess: ChildProcess;

if (options.watch && options.workspaceDocs) {
const _cmd = `${getPackageManagerCommand().exec} nodemon`;
const _cmdArgs = [
'--ignore dist',
'--ext ts',
`--exec "${cmd} ${cmdArgs
.filter((arg) => !arg.startsWith('--watch'))
.join(' ')}"`,
];

options.debug &&
console.log('Spawn Compodoc in nodemon...', {
command: _cmd,
arguments: _cmdArgs,
options: cmdOpts,
});

childProcess = spawn(_cmd, _cmdArgs, cmdOpts);
} else {
options.debug &&
console.log('Spawn Compodoc...', {
command: cmd,
arguments: cmdArgs,
options: cmdOpts,
});

childProcess = spawn(cmd, cmdArgs, cmdOpts);
}

process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
Expand Down

0 comments on commit b0d25c4

Please sign in to comment.