diff --git a/src/generators/json-simple/index.mjs b/src/generators/json-simple/index.mjs index 938e1904..e97daef1 100644 --- a/src/generators/json-simple/index.mjs +++ b/src/generators/json-simple/index.mjs @@ -54,8 +54,15 @@ export default { // This simply grabs all the different files and stringifies them const stringifiedContent = JSON.stringify(mappedInput); - // Writes all the API docs stringified content into one file - // Note: The full JSON generator in the future will create one JSON file per top-level API doc file - await writeFile(join(options.output, 'api-docs.json'), stringifiedContent); + if (options.output) { + // Writes all the API docs stringified content into one file + // Note: The full JSON generator in the future will create one JSON file per top-level API doc file + await writeFile( + join(options.output, 'api-docs.json'), + stringifiedContent + ); + } + + return mappedInput; }, }; diff --git a/src/generators/legacy-html-all/index.mjs b/src/generators/legacy-html-all/index.mjs index 3cbd1ec7..f2e49884 100644 --- a/src/generators/legacy-html-all/index.mjs +++ b/src/generators/legacy-html-all/index.mjs @@ -29,7 +29,7 @@ import { getRemarkRehype } from '../../utils/remark.mjs'; * * @typedef {Array} Input * - * @type {import('../types.d.ts').GeneratorMetadata} + * @type {import('../types.d.ts').GeneratorMetadata} */ export default { name: 'legacy-html-all', @@ -96,6 +96,10 @@ export default { minifyJS: true, }); - await writeFile(join(output, 'all.html'), minified); + if (output) { + await writeFile(join(output, 'all.html'), minified); + } + + return minified; }, }; diff --git a/src/generators/legacy-html/index.mjs b/src/generators/legacy-html/index.mjs index d36e9906..94f91e5b 100644 --- a/src/generators/legacy-html/index.mjs +++ b/src/generators/legacy-html/index.mjs @@ -150,30 +150,34 @@ export default { for (const node of headNodes) { const result = processModuleNodes(node); - // We minify the html result to reduce the file size and keep it "clean" - const minified = await minify(result, { - collapseWhitespace: true, - minifyJS: true, - }); - - await writeFile(join(output, `${node.api}.html`), minified); + if (output) { + // We minify the html result to reduce the file size and keep it "clean" + const minified = await minify(result, { + collapseWhitespace: true, + minifyJS: true, + }); + + await writeFile(join(output, `${node.api}.html`), minified); + } } - // Define the output folder for API docs assets - const assetsFolder = join(output, 'assets'); - - // Removes the current assets directory to copy the new assets - // and prevent stale assets from existing in the output directory - // If the path does not exists, it will simply ignore and continue - await rm(assetsFolder, { recursive: true, force: true }); - - // We copy all the other assets to the output folder at the end of the process - // to ensure that all latest changes on the styles are applied to the output - // Note.: This is not meant to be used for DX/developer purposes. - await cp(join(baseDir, 'assets'), assetsFolder, { - recursive: true, - force: true, - }); + if (output) { + // Define the output folder for API docs assets + const assetsFolder = join(output, 'assets'); + + // Removes the current assets directory to copy the new assets + // and prevent stale assets from existing in the output directory + // If the path does not exists, it will simply ignore and continue + await rm(assetsFolder, { recursive: true, force: true }); + + // We copy all the other assets to the output folder at the end of the process + // to ensure that all latest changes on the styles are applied to the output + // Note.: This is not meant to be used for DX/developer purposes. + await cp(join(baseDir, 'assets'), assetsFolder, { + recursive: true, + force: true, + }); + } return generatedValues; },