Skip to content

Commit 0a60c48

Browse files
committed
add integration tests to validate piping to the CLI
1 parent 8c85ff1 commit 0a60c48

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

integrations/execute.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ module.exports = function $(command, options = {}) {
2121
let abortController = new AbortController()
2222
let cwd = resolveToolRoot()
2323

24-
let args = command.split(' ')
25-
command = args.shift()
26-
command = command === 'node' ? command : path.resolve(cwd, 'node_modules', '.bin', command)
24+
let args = options.shell
25+
? [command]
26+
: (() => {
27+
let args = command.split(' ')
28+
command = args.shift()
29+
command = command === 'node' ? command : path.resolve(cwd, 'node_modules', '.bin', command)
30+
return [command, args]
31+
})()
2732

2833
let stdoutMessages = []
2934
let stderrMessages = []
@@ -55,7 +60,7 @@ module.exports = function $(command, options = {}) {
5560
}, 200)
5661

5762
let runningProcess = new Promise((resolve, reject) => {
58-
let child = spawn(command, args, {
63+
let child = spawn(...args, {
5964
...options,
6065
env: {
6166
...process.env,

integrations/tailwindcss-cli/tests/integration.test.js

+17
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ describe('static build', () => {
2727
)
2828
})
2929

30+
it('should be possible to pipe in data', async () => {
31+
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
32+
33+
await $('cat ./src/index.css | node ../../lib/cli.js -i - -o ./dist/main.css', {
34+
shell: true,
35+
env: { NODE_ENV: 'production' },
36+
})
37+
38+
expect(await readOutputFile('main.css')).toIncludeCss(
39+
css`
40+
.font-bold {
41+
font-weight: 700;
42+
}
43+
`
44+
)
45+
})
46+
3047
it('should safelist a list of classes to always include', async () => {
3148
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
3249
await writeInputFile(

0 commit comments

Comments
 (0)