Skip to content

Commit 752a2c0

Browse files
committed
fixup!
1 parent db0f5aa commit 752a2c0

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

docs/test/index.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,28 @@ const cwd = resolve(__dirname, '..')
77
const output = join(cwd, 'output')
88
const cli = require.resolve(resolve(cwd, '..'))
99

10-
// remove npm config when spawning so config set by test commands don't interfere
11-
const env = Object.fromEntries(
12-
Object.entries(process.env).filter(([k]) => !k.toLowerCase().startsWith('npm_config_'))
13-
)
10+
const rmOutput = () => fs.rm(output, { recursive: true, force: true }).catch(() => {})
1411

15-
const rm = (d) => fs.rm(d, { recursive: true, force: true }).catch(() => {})
12+
const spawnNpm = (args, opts) => {
13+
// remove npm config when spawning so config set by test commands don't interfere
14+
const env = Object.entries(process.env)
15+
.filter(([k]) => !k.toLowerCase().startsWith('npm_config_'))
16+
17+
return spawn('node', [cli, ...args], {
18+
env: Object.fromEntries(env),
19+
stdioString: true,
20+
...opts,
21+
})
22+
}
1623

1724
t.test('docs', async (t) => {
18-
t.teardown(() => rm(output))
25+
t.teardown(rmOutput)
1926

20-
await rm(output)
27+
await rmOutput()
2128
t.rejects(() => fs.stat(output))
2229

23-
const docs = await spawn('node', [cli, 'run', 'build'], {
24-
cwd,
25-
env,
26-
stdioString: true,
27-
})
30+
// calling run build will rebuild cmark-gfm with a prebuild script
31+
const docs = await spawnNpm(['run', 'build'], { cwd })
2832

2933
t.equal(docs.code, 0)
3034
t.ok((await fs.stat(output)).isDirectory())

0 commit comments

Comments
 (0)