Skip to content

Commit

Permalink
Use pnpm pack for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Nov 30, 2022
1 parent b0aa73b commit c80c1e7
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions .github/actions/next-stats-action/src/prepare/repo-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,21 @@ module.exports = (actionInfo) => {
continue
}
const pkgData = require(pkgDataPath)
const { name } = pkgData
if (pkgData?.scripts?.prepublishOnly) {
// There's a bug in `pnpm pack` where it will run
// the prepublishOnly script and that will fail.
// See https://github.com/pnpm/pnpm/issues/2941
delete pkgData.scripts.prepublishOnly
await fs.writeFile(pkgDataPath, JSON.stringify(pkgData, null, 2))
}
const { name, version } = pkgData
pkgDatas.set(name, {
pkgDataPath,
pkg,
pkgPath,
pkgData,
packedPkgPath,
version,
})
pkgPaths.set(name, packedPkgPath)
}
Expand Down Expand Up @@ -130,8 +138,15 @@ module.exports = (actionInfo) => {
// wait to pack packages until after dependency paths have been updated
// to the correct versions
for (const pkgName of pkgDatas.keys()) {
const { pkg, pkgPath } = pkgDatas.get(pkgName)
await exec(`cd ${pkgPath} && yarn pack -f ${pkg}-packed.tgz`, true)
const { pkg, pkgPath, version } = pkgDatas.get(pkgName)
await exec(`cd ${pkgPath} && pnpm pack`, true)
const files = await fs.readdir(pkgPath)
const oldName = files.find((f) =>
new RegExp(`${pkg}.${version}.tgz$`).test(f)
)
const newName = path.join(pkgPath, `${pkg}-packed.tgz`)
console.log(`renaming ${oldName} to ${newName}`)
await fs.move(oldName, newName)
}
return pkgPaths
},
Expand Down

0 comments on commit c80c1e7

Please sign in to comment.