(tarballPath, targetPath)
| 49 | } |
| 50 | |
| 51 | function readFileFromTarball(tarballPath, targetPath) { |
| 52 | const buffer = gunzipSync(readFileSync(tarballPath)); |
| 53 | |
| 54 | for (let offset = 0; offset < buffer.length; ) { |
| 55 | const name = readTarString(buffer, offset, 100); |
| 56 | if (!name) { |
| 57 | break; |
| 58 | } |
| 59 | |
| 60 | const prefix = readTarString(buffer, offset + 345, 155); |
| 61 | const path = prefix ? `${prefix}/${name}` : name; |
| 62 | const size = parseInt(readTarString(buffer, offset + 124, 12).trim() || '0', 8); |
| 63 | const contentOffset = offset + 512; |
| 64 | |
| 65 | if (path === targetPath) { |
| 66 | return buffer.toString('utf8', contentOffset, contentOffset + size); |
| 67 | } |
| 68 | |
| 69 | offset = contentOffset + Math.ceil(size / 512) * 512; |
| 70 | } |
| 71 | |
| 72 | throw new Error(`Missing ${targetPath} in ${tarballPath}`); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Every non-private package in the pnpm workspace, i.e. exactly the set that |
no test coverage detected