MCPcopy
hub / github.com/vercel/next.js / fsToJson

Function fsToJson

test/integration/image-optimizer/test/util.ts:95–111  ·  view source on GitHub ↗
(dir: string, output = {})

Source from the content-addressed store, hash-verified

93}
94
95export async function fsToJson(dir: string, output = {}) {
96 const files = await fs.readdir(dir).catch((e: Error) => e)
97 if (!Array.isArray(files)) {
98 return output
99 }
100 for (let file of files) {
101 const fsPath = join(dir, file)
102 const stat = await fs.stat(fsPath)
103 if (stat.isDirectory()) {
104 output[file] = {}
105 await fsToJson(fsPath, output[file])
106 } else {
107 output[file] = stat.mtime.toISOString()
108 }
109 }
110 return output
111}
112
113export async function expectWidth(res, w, { expectAnimated = false } = {}) {
114 const buffer = await res.buffer()

Callers 2

index.test.tsFile · 0.90
runTestsFunction · 0.85

Calls 5

joinFunction · 0.90
isArrayMethod · 0.80
isDirectoryMethod · 0.80
statMethod · 0.65
catchMethod · 0.45

Tested by

no test coverage detected