( files: FilesMap, clientOptions: VercelClientOptions )
| 389 | const isWin = process.platform.includes('win'); |
| 390 | |
| 391 | export const prepareFiles = ( |
| 392 | files: FilesMap, |
| 393 | clientOptions: VercelClientOptions |
| 394 | ): PreparedFile[] => { |
| 395 | const preparedFiles: PreparedFile[] = []; |
| 396 | for (const [sha, file] of files) { |
| 397 | for (const name of file.names) { |
| 398 | let fileName: string; |
| 399 | |
| 400 | if (clientOptions.isDirectory) { |
| 401 | // Directory |
| 402 | fileName = |
| 403 | typeof clientOptions.path === 'string' |
| 404 | ? relative(clientOptions.path, name) |
| 405 | : name; |
| 406 | } else { |
| 407 | // Array of files or single file |
| 408 | const segments = name.split(sep); |
| 409 | fileName = segments[segments.length - 1]; |
| 410 | } |
| 411 | |
| 412 | preparedFiles.push({ |
| 413 | file: isWin ? fileName.replace(/\\/g, '/') : fileName, |
| 414 | size: file.data?.byteLength ?? file.size, |
| 415 | mode: file.mode, |
| 416 | sha: sha || undefined, |
| 417 | }); |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | return preparedFiles; |
| 422 | }; |
| 423 | |
| 424 | export function createDebug(debug?: boolean) { |
| 425 | if (debug) { |
no test coverage detected