Skip to content

Commit

Permalink
Ensure swc dep is copied for isolated tests (#31462)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Nov 15, 2021
1 parent b51a020 commit a9eb0de
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/lib/create-next-install.js
Expand Up @@ -11,6 +11,25 @@ async function createNextInstall(dependencies) {
const installDir = path.join(tmpDir, `next-install-${Date.now()}`)
const tmpRepoDir = path.join(tmpDir, `next-repo-${Date.now()}`)

// ensure swc binary is present in the native folder if
// not already built
for (const folder of await fs.readdir(
path.join(origRepoDir, 'node_modules/@next')
)) {
if (folder.startsWith('swc-')) {
const swcPkgPath = path.join(origRepoDir, 'node_modules/@next', folder)
await fs.copy(
swcPkgPath,
path.join(origRepoDir, 'packages/next/native'),
{
filter: (item) =>
item === swcPkgPath ||
(item.endsWith('.node') && !fs.pathExistsSync(item)),
}
)
}
}

for (const item of ['package.json', 'yarn.lock', 'packages']) {
await fs.copy(path.join(origRepoDir, item), path.join(tmpRepoDir, item), {
filter: (item) => {
Expand All @@ -23,6 +42,7 @@ async function createNextInstall(dependencies) {
},
})
}

const pkgPaths = await linkPackages(tmpRepoDir)

await fs.ensureDir(installDir)
Expand Down

0 comments on commit a9eb0de

Please sign in to comment.