Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js « test « docs - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fab9748a3ae3d4013624a6796139fc458f994739 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const t = require('tap')
const spawn = require('@npmcli/promise-spawn')
const fs = require('@npmcli/fs')
const { resolve, join } = require('path')
const which = require('which').sync

const cwd = resolve(__dirname, '..')
const output = join(cwd, 'output')

const rmOutput = () => fs.rm(output, { recursive: true, force: true }).catch(() => {})

const spawnNpm = (...args) => {
  // remove npm config when spawning so config set by test commands don't interfere
  const env = Object.entries(process.env)
    .filter(([k]) => k.toLowerCase() !== 'npm_config_ignore_scripts')

  return spawn(which('npm'), args, {
    env: Object.fromEntries(env),
    stdioString: true,
    cwd,
  })
}

t.before(() => spawnNpm('rebuild', 'cmark-gfm'))
t.beforeEach(() => rmOutput())

t.test('docs', async (t) => {
  t.rejects(() => fs.stat(output))
  const docs = await spawnNpm('run', 'build')
  t.equal(docs.code, 0)
  t.ok((await fs.stat(output)).isDirectory())
})

t.test('files used by documention repo', async (t) => {
  t.ok((await fs.stat(join(cwd, 'content'))).isDirectory())
  t.ok((await fs.stat(join(cwd, 'nav.yml'))).isFile())
})