MCPcopy Create free account
hub / github.com/arktypeio/arktype / walk

Function walk

ark/aot/nextProgram.ts:242–270  ·  view source on GitHub ↗
(dir: string, isLinked: boolean)

Source from the content-addressed store, hash-verified

240 dirs.some(dir => path === dir || path.startsWith(`${dir}${sep}`))
241 // a file reached through a link is read as Turbopack reads it, by where it is
242 const walk = (dir: string, isLinked: boolean) => {
243 const isRoot = dir === root
244 const isRoutes = isUnder(dir, routes)
245 const isPages = isUnder(dir, pages)
246 const key = `${isRoot}${isRoutes}${isPages}${realPathOf(dir)}`
247 if (walked.has(key)) return
248 walked.add(key)
249 for (const entry of readdirSync(dir, { withFileTypes: true })) {
250 const path = join(dir, entry.name)
251 const isLink = entry.isSymbolicLink()
252 const stats = isLink ? statOf(path) : entry
253 if (!stats || entry.name === "node_modules") continue
254 if (!isPages) {
255 if (entry.name.startsWith(".") && (isRoot || !isRoutes)) continue
256 if (isRoot && skippedAtRoot.has(entry.name)) continue
257 }
258 if (stats.isDirectory()) {
259 if (isPages || !testDirs.has(entry.name)) walk(path, isLinked || isLink)
260 } else if (stats.isFile()) {
261 if (scriptFile.test(entry.name)) {
262 if (
263 !declarationFile.test(entry.name) &&
264 (isPages || !unbuiltFile.test(entry.name))
265 )
266 scripts.add(isLinked || isLink ? realPathOf(path) : path)
267 } else if (foreignFile.test(entry.name)) tree.foreign ??= path
268 }
269 }
270 }
271 walk(root, false)
272 tree.scripts = [...scripts].sort()
273 return tree

Callers 1

treeOfFunction · 0.70

Calls 7

realPathOfFunction · 0.90
isUnderFunction · 0.85
joinFunction · 0.85
statOfFunction · 0.85
testMethod · 0.80
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected