Skip to content

Commit 8e465ce

Browse files
committed
print the mkdocs output when running the generate command with the --verbose flag
Signed-off-by: Morgan Bentell <[email protected]>
1 parent f16d9f3 commit 8e465ce

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.changeset/quick-coats-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@techdocs/cli': minor
3+
---
4+
5+
Running `@techdocs/cli generate` with the `--verbose` flag will now print the mkdocs output.

packages/techdocs-cli/src/commands/generate/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import { ConfigReader } from '@backstage/config';
3131
import {
3232
convertTechDocsRefToLocationAnnotation,
3333
createLogger,
34+
getLogStream,
3435
} from '../../lib/utility';
35-
import { stdout } from 'process';
3636

3737
export default async function generate(opts: OptionValues) {
3838
// Use techdocs-node package to generate docs. Keep consistency between Backstage and CI generating docs.
@@ -110,7 +110,7 @@ export default async function generate(opts: OptionValues) {
110110
: {}),
111111
logger,
112112
etag: opts.etag,
113-
...(process.env.LOG_LEVEL === 'debug' ? { logStream: stdout } : {}),
113+
logStream: getLogStream(logger),
114114
siteOptions: { name: opts.siteName },
115115
});
116116

packages/techdocs-cli/src/lib/utility.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
ParsedLocationAnnotation,
1919
} from '@backstage/plugin-techdocs-node';
2020
import * as winston from 'winston';
21+
import { Writable } from 'stream';
22+
import { stdout } from 'process';
2123

2224
export const convertTechDocsRefToLocationAnnotation = (
2325
techdocsRef: string,
@@ -52,3 +54,17 @@ export const createLogger = ({
5254

5355
return logger;
5456
};
57+
58+
export const getLogStream = (logger: winston.Logger): Writable => {
59+
if (process.env.LOG_LEVEL === 'debug') {
60+
return stdout;
61+
}
62+
63+
return new Writable({
64+
defaultEncoding: 'utf8',
65+
write(chunk, _encoding, next) {
66+
logger.verbose(chunk.toString().trim());
67+
next();
68+
},
69+
});
70+
};

0 commit comments

Comments
 (0)