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 b042956 commit a8ee6ad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
8 changes: 3 additions & 5 deletions integrations/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ 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 stdoutMessages = []
let stderrMessages = []

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

let runningProcess = new Promise((resolve, reject) => {
let child = spawn(command, args, {
let child = spawn(command, {
stdio: 'inherit',
shell: true,
...options,
env: {
...process.env,
Expand Down
22 changes: 22 additions & 0 deletions integrations/tailwindcss-cli/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ describe('static build', () => {
)
})

it('should be possible to pipe in data', async () => {
await writeInputFile('index.html', html`<div class="font-bold"></div>`)

let initialCss = css`
@tailwind base;
@tailwind components;
@tailwind utilities;
`

await $('cat ./src/index.css | node ../../lib/cli.js -o ./dist/main.css', {
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 a8ee6ad

Please sign in to comment.