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

Function copySkillTree

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

Source from the content-addressed store, hash-verified

266}
267
268const copySkillTree = (srcDir: string, destDir: string): void => {
269 for (const entry of readdirSync(srcDir, { withFileTypes: true })) {
270 const srcPath = join(srcDir, entry.name)
271 const destPath = join(destDir, entry.name)
272 const destStat = lstatIfExists(destPath)
273 if (destStat?.isSymbolicLink())
274 throw new Error(`Refusing to write through symlink at ${destPath}`)
275 if (entry.isDirectory()) {
276 if (destStat && !destStat.isDirectory()) {
277 throw new Error(
278 `Cannot create directory at ${destPath}: path exists and is not a directory`
279 )
280 }
281 if (!destStat) mkdirSync(destPath)
282 copySkillTree(srcPath, destPath)
283 } else if (entry.isFile()) {
284 if (destStat) {
285 if (!destStat.isFile()) {
286 throw new Error(
287 `Cannot write file at ${destPath}: path exists and is not a regular file`
288 )
289 }
290 unlinkSync(destPath)
291 }
292 copyFileSync(srcPath, destPath, constants.COPYFILE_EXCL)
293 }
294 }
295}
296
297type PreparedSkillInstall = {
298 dest: string

Callers 1

applySkillInstallFunction · 0.85

Calls 2

joinFunction · 0.85
lstatIfExistsFunction · 0.85

Tested by

no test coverage detected