mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
- when used on the CLI, lib/cli.js was writing the output of log statements to STDOUT; this caused consumers of the CLI who wanted to pipe the processed output (css) to other unix utilities to end up with invalid CSS due to the log messages appearing at the start and end of the files - this commit fixes this by replacing `console.log` with `console.warn` and `console.error`, which both write output to STDERR
22 lines
651 B
JavaScript
22 lines
651 B
JavaScript
import { spawnSync } from 'child_process'
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
function runCli(task, options) {
|
|
return spawnSync('node', [`${path.join(process.cwd(), 'lib/cli.js')}`, `${task}`, ...options])
|
|
}
|
|
|
|
function pathToFixture(fixture) {
|
|
return path.resolve(`${__dirname}/fixtures/${fixture}`)
|
|
}
|
|
|
|
function readFixture(fixture) {
|
|
return fs.readFileSync(pathToFixture(fixture), 'utf8')
|
|
}
|
|
|
|
test('stdout only contains processed output', () => {
|
|
const expected = readFixture('tailwind-cli-output.css')
|
|
const result = runCli('build', [pathToFixture('tailwind-cli-input.css')])
|
|
expect(result.stdout.toString()).toEqual(expected)
|
|
})
|