( root: string, rel: string, targetDir: string )
| 3298 | } |
| 3299 | |
| 3300 | export async function moveAsset( |
| 3301 | root: string, |
| 3302 | rel: string, |
| 3303 | targetDir: string |
| 3304 | ): Promise<AssetMeta> { |
| 3305 | const source = await assertAssetFile(root, rel) |
| 3306 | const destDir = cleanAssetTargetDir(root, targetDir) |
| 3307 | await fs.mkdir(destDir, { recursive: true }) |
| 3308 | if (path.resolve(destDir) === path.dirname(source.abs)) return await assetMetaForPath(root, source.abs) |
| 3309 | const finalName = await uniqueFilename(destDir, path.basename(source.abs)) |
| 3310 | const destAbs = path.join(destDir, finalName) |
| 3311 | if (destAbs !== source.abs) await fs.rename(source.abs, destAbs) |
| 3312 | return await assetMetaForPath(root, destAbs) |
| 3313 | } |
| 3314 | |
| 3315 | export async function duplicateAsset(root: string, rel: string): Promise<AssetMeta> { |
| 3316 | const source = await assertAssetFile(root, rel) |
no test coverage detected