Skip to content

Commit a8ee6ad

Browse files
committed
add integration tests to validate piping to the CLI
1 parent b042956 commit a8ee6ad

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

integrations/execute.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ 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)
27-
2824
let stdoutMessages = []
2925
let stderrMessages = []
3026

@@ -55,7 +51,9 @@ module.exports = function $(command, options = {}) {
5551
}, 200)
5652

5753
let runningProcess = new Promise((resolve, reject) => {
58-
let child = spawn(command, args, {
54+
let child = spawn(command, {
55+
stdio: 'inherit',
56+
shell: true,
5957
...options,
6058
env: {
6159
...process.env,

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

+22
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ 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+
let initialCss = css`
34+
@tailwind base;
35+
@tailwind components;
36+
@tailwind utilities;
37+
`
38+
39+
await $('cat ./src/index.css | node ../../lib/cli.js -o ./dist/main.css', {
40+
env: { NODE_ENV: 'production' },
41+
})
42+
43+
expect(await readOutputFile('main.css')).toIncludeCss(
44+
css`
45+
.font-bold {
46+
font-weight: 700;
47+
}
48+
`
49+
)
50+
})
51+
3052
it('should safelist a list of classes to always include', async () => {
3153
await writeInputFile('index.html', html`<div class="font-bold"></div>`)
3254
await writeInputFile(

0 commit comments

Comments
 (0)