Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"yargs": "^18.0.0"
},
"devDependencies": {
"ava": "^3.1.0",
"ava": "^8.0.0",
"c8": "^12.0.0",
"eslint": "^10.0.0",
"eslint-config-problems": "10.0.1",
Expand Down
30 changes: 16 additions & 14 deletions test/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ import { exec } from 'node:child_process'
import tmp from './helpers/tmp.js'
import read from './helpers/read.js'

test.cb('reads from stdin', (t) => {
test('reads from stdin', (t) => {
const output = tmp('output.css')

const cp = exec(
`node ${path.resolve('index.js')} -o ${output} --no-map`,
(error, stdout, stderr) => {
if (error) t.end(error, stderr)
return new Promise((resolve, reject) => {
const cp = exec(
`node ${path.resolve('index.js')} -o ${output} --no-map`,
(error) => {
if (error) return reject(error)

Promise.all([read(output), read('test/fixtures/a.css')])
.then(([a, e]) => {
t.is(a, e)
t.end()
})
.catch(t.end)
},
)
Promise.all([read(output), read('test/fixtures/a.css')])
.then(([a, e]) => {
t.is(a, e)
resolve()
})
.catch(reject)
},
)

createReadStream('test/fixtures/a.css').pipe(cp.stdin)
createReadStream('test/fixtures/a.css').pipe(cp.stdin)
})
})
37 changes: 21 additions & 16 deletions test/stdout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@ import { exec } from 'node:child_process'

import read from './helpers/read.js'

test.cb('writes to stdout', (t) => {
const cp = exec(
`node ${path.resolve(
'index.js',
)} --parser sugarss -u postcss-import --no-map`,
(error, stdout, stderr) => {
if (error) t.end(error, stderr)
test('writes to stdout', (t) => {
return new Promise((resolve, reject) => {
const cp = exec(
`node ${path.resolve(
'index.js',
)} --parser sugarss -u postcss-import --no-map`,
(error, stdout) => {
if (error) return reject(error)

Promise.all([stdout.replace(/\r\n/g, '\n'), read('test/fixtures/s.css')])
.then(([a, e]) => {
t.is(a, e)
t.end()
})
.catch(t.end)
},
)
Promise.all([
stdout.replace(/\r\n/g, '\n'),
read('test/fixtures/s.css'),
])
.then(([a, e]) => {
t.is(a, e)
resolve()
})
.catch(reject)
},
)

createReadStream('./test/fixtures/a.sss').pipe(cp.stdin)
createReadStream('./test/fixtures/a.sss').pipe(cp.stdin)
})
})