Skip to content

Commit

Permalink
Write to stdout in watch mode if no output file provided
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Jun 5, 2021
1 parent bd20d2c commit 67ee5e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,9 @@ async function build() {
function processCSS(css) {
let start = process.hrtime.bigint()
return Promise.resolve()
.then(() => fs.promises.mkdir(path.dirname(output), { recursive: true }))
.then(() =>
output ? fs.promises.mkdir(path.dirname(output), { recursive: true }) : null
)
.then(() => processor.process(css, { from: input, to: output }))
.then(async (result) => {
for (let message of result.messages) {
Expand All @@ -556,6 +558,10 @@ async function build() {
}
watcher.add([...contextDependencies])

if (!output) {
return process.stdout.write(result.css)
}

await Promise.all(
[
fs.promises.writeFile(output, result.css, () => true),
Expand Down

0 comments on commit 67ee5e0

Please sign in to comment.