Write to stdout in watch mode if no output file provided

This commit is contained in:
Adam Wathan 2021-06-05 16:38:54 -04:00
parent bd20d2c0fa
commit 67ee5e033d

View file

@ -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) {
@ -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),