Skip to content

Commit

Permalink
fix: handle output path as false
Browse files Browse the repository at this point in the history
  • Loading branch information
saibotsivad committed Mar 22, 2024
1 parent 85a3771 commit daf1ccc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-walls-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hunch": patch
---

Allow output to be false explicitly in more places.
10 changes: 7 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit daf1ccc

Please sign in to comment.