Skip to content

Commit 0c9b9ec

Browse files
authored
test: instructions when encountering symlink error on Windows (#7470)
1 parent e24dc85 commit 0c9b9ec

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

scripts/jestGlobalSetup.cjs

+17-7
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,21 @@ module.exports = async () => {
2121

2222
const tempDir = path.resolve(__dirname, '../packages/temp')
2323
await fs.remove(tempDir)
24-
await fs.copy(path.resolve(__dirname, '../packages/playground'), tempDir, {
25-
dereference: false,
26-
filter(file) {
27-
file = file.replace(/\\/g, '/')
28-
return !file.includes('__tests__') && !file.match(/dist(\/|$)/)
29-
}
30-
})
24+
await fs
25+
.copy(path.resolve(__dirname, '../packages/playground'), tempDir, {
26+
dereference: false,
27+
filter(file) {
28+
file = file.replace(/\\/g, '/')
29+
return !file.includes('__tests__') && !file.match(/dist(\/|$)/)
30+
}
31+
})
32+
.catch(async (error) => {
33+
if (error.code === 'EPERM' && error.syscall === 'symlink') {
34+
throw new Error(
35+
'Could not create symlinks. On Windows, consider activating Developer Mode to allow non-admin users to create symlinks by following the instructions at https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development.'
36+
)
37+
} else {
38+
throw error
39+
}
40+
})
3141
}

0 commit comments

Comments
 (0)