(t, { stdin: stdinLines, registry: registryUrl, ...options } = {})
| 9 | const stream = require('node:stream') |
| 10 | |
| 11 | const mockAddUser = async (t, { stdin: stdinLines, registry: registryUrl, ...options } = {}) => { |
| 12 | if (stdinLines) { |
| 13 | const stdin = new stream.PassThrough() |
| 14 | for (const l of stdinLines) { |
| 15 | stdin.write(l + '\n') |
| 16 | } |
| 17 | mockGlobals(t, { |
| 18 | 'process.stdin': stdin, |
| 19 | 'process.stdout': new stream.PassThrough(), // to quiet readline |
| 20 | }, { replace: true }) |
| 21 | } |
| 22 | const mock = await loadMockNpm(t, { |
| 23 | ...options, |
| 24 | command: 'adduser', |
| 25 | }) |
| 26 | const registry = new MockRegistry({ |
| 27 | tap: t, |
| 28 | registry: registryUrl ?? mock.npm.config.get('registry'), |
| 29 | }) |
| 30 | return { |
| 31 | registry, |
| 32 | rc: () => ini.parse(fs.readFileSync(path.join(mock.home, '.npmrc'), 'utf8')), |
| 33 | ...mock, |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | t.test('usage', async t => { |
| 38 | const { adduser } = await loadMockNpm(t, { command: 'adduser' }) |
no test coverage detected
searching dependent graphs…