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

Function validateSkillTree

ark/type/cli.ts:246–266  ·  view source on GitHub ↗
(srcDir: string, destDir: string)

Source from the content-addressed store, hash-verified

244}
245
246const validateSkillTree = (srcDir: string, destDir: string): void => {
247 for (const entry of readdirSync(srcDir, { withFileTypes: true })) {
248 const srcPath = join(srcDir, entry.name)
249 const destPath = join(destDir, entry.name)
250 const destStat = lstatIfExists(destPath)
251 if (destStat?.isSymbolicLink())
252 throw new Error(`Refusing to write through symlink at ${destPath}`)
253 if (entry.isDirectory()) {
254 if (destStat && !destStat.isDirectory()) {
255 throw new Error(
256 `Cannot create directory at ${destPath}: path exists and is not a directory`
257 )
258 }
259 validateSkillTree(srcPath, destPath)
260 } else if (entry.isFile() && destStat && !destStat.isFile()) {
261 throw new Error(
262 `Cannot write file at ${destPath}: path exists and is not a regular file`
263 )
264 }
265 }
266}
267
268const copySkillTree = (srcDir: string, destDir: string): void => {
269 for (const entry of readdirSync(srcDir, { withFileTypes: true })) {

Callers 1

prepareSkillInstallFunction · 0.85

Calls 2

joinFunction · 0.85
lstatIfExistsFunction · 0.85

Tested by

no test coverage detected