| 109 | } |
| 110 | |
| 111 | function packAll(packages, destination) { |
| 112 | mkdirSync(destination, { recursive: true }); |
| 113 | const tarballs = {}; |
| 114 | for (const pkg of packages) { |
| 115 | const stdout = run( |
| 116 | `pack ${pkg.name}`, |
| 117 | `pnpm pack --pack-destination "${destination}" --json`, |
| 118 | pkg.path, |
| 119 | ); |
| 120 | // pnpm may print lifecycle output before the JSON document. |
| 121 | const { filename } = JSON.parse(stdout.slice(stdout.indexOf('{'))); |
| 122 | tarballs[pkg.name] = `file:${filename}`; |
| 123 | } |
| 124 | return tarballs; |
| 125 | } |
| 126 | |
| 127 | function writeJson(path, value) { |
| 128 | writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`); |