MCPcopy Index your code
hub / github.com/nodejs/node / mockAddUser

Function mockAddUser

deps/npm/test/lib/commands/adduser.js:11–35  ·  view source on GitHub ↗
(t, { stdin: stdinLines, registry: registryUrl, ...options } = {})

Source from the content-addressed store, hash-verified

9const stream = require('node:stream')
10
11const 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
37t.test('usage', async t => {
38 const { adduser } = await loadMockNpm(t, { command: 'adduser' })

Callers 1

adduser.jsFile · 0.85

Calls 6

loadMockNpmFunction · 0.70
getMethod · 0.65
parseMethod · 0.65
writeMethod · 0.45
readFileSyncMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…