Skip to content

Commit 4959c9e

Browse files
Update dependency ava to v8 (#514)
* Update dependency ava to v8 * Update stdin/stdout tests to use promises --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ryan Zimmerman <opensrc@ryanzim.com>
1 parent b92aa6f commit 4959c9e

3 files changed

Lines changed: 38 additions & 31 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"yargs": "^18.0.0"
3131
},
3232
"devDependencies": {
33-
"ava": "^3.1.0",
33+
"ava": "^8.0.0",
3434
"c8": "^12.0.0",
3535
"eslint": "^10.0.0",
3636
"eslint-config-problems": "10.0.1",

test/stdin.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,24 @@ import { exec } from 'node:child_process'
77
import tmp from './helpers/tmp.js'
88
import read from './helpers/read.js'
99

10-
test.cb('reads from stdin', (t) => {
10+
test('reads from stdin', (t) => {
1111
const output = tmp('output.css')
1212

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

18-
Promise.all([read(output), read('test/fixtures/a.css')])
19-
.then(([a, e]) => {
20-
t.is(a, e)
21-
t.end()
22-
})
23-
.catch(t.end)
24-
},
25-
)
19+
Promise.all([read(output), read('test/fixtures/a.css')])
20+
.then(([a, e]) => {
21+
t.is(a, e)
22+
resolve()
23+
})
24+
.catch(reject)
25+
},
26+
)
2627

27-
createReadStream('test/fixtures/a.css').pipe(cp.stdin)
28+
createReadStream('test/fixtures/a.css').pipe(cp.stdin)
29+
})
2830
})

test/stdout.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@ import { exec } from 'node:child_process'
66

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

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

17-
Promise.all([stdout.replace(/\r\n/g, '\n'), read('test/fixtures/s.css')])
18-
.then(([a, e]) => {
19-
t.is(a, e)
20-
t.end()
21-
})
22-
.catch(t.end)
23-
},
24-
)
18+
Promise.all([
19+
stdout.replace(/\r\n/g, '\n'),
20+
read('test/fixtures/s.css'),
21+
])
22+
.then(([a, e]) => {
23+
t.is(a, e)
24+
resolve()
25+
})
26+
.catch(reject)
27+
},
28+
)
2529

26-
createReadStream('./test/fixtures/a.sss').pipe(cp.stdin)
30+
createReadStream('./test/fixtures/a.sss').pipe(cp.stdin)
31+
})
2732
})

0 commit comments

Comments
 (0)