diff --git a/.changeset/nasty-walls-bow.md b/.changeset/nasty-walls-bow.md new file mode 100644 index 0000000..01722ea --- /dev/null +++ b/.changeset/nasty-walls-bow.md @@ -0,0 +1,5 @@ +--- +"hunch": patch +--- + +Allow output to be false explicitly in more places. diff --git a/src/cli.js b/src/cli.js index 97ca60f..5f02439 100644 --- a/src/cli.js +++ b/src/cli.js @@ -31,14 +31,18 @@ const build = async ({ cwd, indent, opts, outputFilepath, verbose }) => { } } +const optionalMkdir = async (filepath) => { + if (filepath) return mkdir(dirname(filepath), { recursive: true }) +} + const run = async ({ config, cwd, delay, indent, serve, verbose, watch }) => new Promise( (resolvePromise, rejectPromise) => import(pathToFileURL(config).href) .then(({ default: opts }) => { const port = typeof serve === 'number' ? serve : 9001 let { output: outputFilepath } = opts - if (!outputFilepath) throw new Error('Must specify an output filepath.') - if (!isAbsolute(outputFilepath)) outputFilepath = resolve(cwd, outputFilepath) - mkdir(dirname(outputFilepath), { recursive: true }) + if (!outputFilepath && outputFilepath !== false) throw new Error('Must specify an output filepath.') + if (outputFilepath && !isAbsolute(outputFilepath)) outputFilepath = resolve(cwd, outputFilepath) + optionalMkdir(outputFilepath) .then(() => { if (watch) { const watch = new CheapWatch({