MCPcopy Create free account
hub / github.com/npm/cli / jsonifyTestdir

Function jsonifyTestdir

test/lib/commands/diff.js:6–17  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

4const { load: loadMockNpm } = require('../../fixtures/mock-npm')
5
6const jsonifyTestdir = (obj) => {
7 for (const [key, value] of Object.entries(obj || {})) {
8 if (extname(key) === '.json') {
9 obj[key] = JSON.stringify(value, null, 2) + '\n'
10 } else if (typeof value === 'object') {
11 obj[key] = jsonifyTestdir(value)
12 } else {
13 obj[key] = value.trim() + '\n'
14 }
15 }
16 return obj
17}
18
19// generic helper to call diff with a specified dir contents and registry calls
20const mockDiff = async (t, {

Callers 1

mockDiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected