( assets: Set<string>, cwd: string, out: string, written: Set<string> )
| 219 | } |
| 220 | |
| 221 | async function copyAssets( |
| 222 | assets: Set<string>, |
| 223 | cwd: string, |
| 224 | out: string, |
| 225 | written: Set<string> |
| 226 | ): Promise<number> { |
| 227 | let copied = 0; |
| 228 | let realCwd = await realpath(cwd); |
| 229 | let realOut = await realpath(out).catch(() => out); |
| 230 | for (let src of assets) { |
| 231 | if (!isInsideOrEqual(cwd, src)) continue; |
| 232 | if (isInsideOrEqual(out, src)) continue; |
| 233 | if (hasIgnoredPathPart(src, cwd)) continue; |
| 234 | let dest = resolve(out, relative(cwd, src)); |
| 235 | if (written.has(dest)) continue; |
| 236 | if (!isInsideOrEqual(out, dest)) continue; |
| 237 | let stat: Awaited<ReturnType<typeof lstat>>; |
| 238 | let copyFrom = src; |
| 239 | try { |
| 240 | if (await hasSymlinkParentPathPart(src, cwd)) continue; |
| 241 | stat = await lstat(src); |
| 242 | if (stat.isSymbolicLink()) { |
| 243 | let realSrc = await realpath(src); |
| 244 | if (!isInsideOrEqual(realCwd, realSrc)) continue; |
| 245 | if (isInsideOrEqual(realOut, realSrc)) continue; |
| 246 | if (hasIgnoredPathPart(realSrc, realCwd)) continue; |
| 247 | copyFrom = realSrc; |
| 248 | stat = await lstat(realSrc); |
| 249 | } |
| 250 | } catch { |
| 251 | continue; |
| 252 | } |
| 253 | if (!stat.isFile()) continue; |
| 254 | await mkdir(dirname(dest), { recursive: true }); |
| 255 | await copyFile(copyFrom, dest); |
| 256 | written.add(dest); |
| 257 | copied++; |
| 258 | } |
| 259 | return copied; |
| 260 | } |
no test coverage detected
searching dependent graphs…