Skip to content

Commit

Permalink
add integration tests to validate piping to the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Jan 4, 2022
1 parent 8c85ff1 commit 0a60c48
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
13 changes: 9 additions & 4 deletions integrations/execute.js
Expand Up @@ -21,9 +21,14 @@ module.exports = function $(command, options = {}) {
let abortController = new AbortController()
let cwd = resolveToolRoot()

let args = command.split(' ')
command = args.shift()
command = command === 'node' ? command : path.resolve(cwd, 'node_modules', '.bin', command)
let args = options.shell
? [command]
: (() => {
let args = command.split(' ')
command = args.shift()
command = command === 'node' ? command : path.resolve(cwd, 'node_modules', '.bin', command)
return [command, args]
})()

let stdoutMessages = []
let stderrMessages = []
Expand Down Expand Up @@ -55,7 +60,7 @@ module.exports = function $(command, options = {}) {
}, 200)

let runningProcess = new Promise((resolve, reject) => {
let child = spawn(command, args, {
let child = spawn(...args, {
...options,
env: {
...process.env,
Expand Down
17 changes: 17 additions & 0 deletions integrations/tailwindcss-cli/tests/integration.test.js
Expand Up @@ -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(
Expand Down

0 comments on commit 0a60c48

Please sign in to comment.