Allow piping data into the CLI (#6876)

* use outputFile instead of direct writeFile

This is an improvement we introduced earlier but forgot this part.

* allow to pipe in data to the CLI

* add integration tests to validate piping to the CLI

* update changelog
This commit is contained in:
Robin Malfait 2022-01-04 18:58:55 +01:00 • committed by GitHub
parent 058a9256ae
commit 657bf5f8c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 13 deletions

View file

@ -27,6 +27,23 @@ describe('static build', () => {
)
})
it('should be possible to pipe in data', async () => {
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
await $('cat ./src/index.css | node ../../lib/cli.js -i - -o ./dist/main.css', {
shell: true,
env: { NODE_ENV: 'production' },
})
expect(await readOutputFile('main.css')).toIncludeCss(
css`
.font-bold {
font-weight: 700;
}
`
)
})
it('should safelist a list of classes to always include', async () => {
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
await writeInputFile(