From 0d7ef43984ce62efca7db4ca10eb93a6998eb9be Mon Sep 17 00:00:00 2001 From: Johannes Maas Date: Sat, 26 Mar 2022 12:19:14 +0100 Subject: [PATCH] test: instructions when encountering symlink error on Windows (#7470) --- scripts/jestGlobalSetup.cjs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/jestGlobalSetup.cjs b/scripts/jestGlobalSetup.cjs index 9640f70c5a8291..7341cba40968d9 100644 --- a/scripts/jestGlobalSetup.cjs +++ b/scripts/jestGlobalSetup.cjs @@ -21,11 +21,21 @@ module.exports = async () => { const tempDir = path.resolve(__dirname, '../packages/temp') await fs.remove(tempDir) - await fs.copy(path.resolve(__dirname, '../packages/playground'), tempDir, { - dereference: false, - filter(file) { - file = file.replace(/\\/g, '/') - return !file.includes('__tests__') && !file.match(/dist(\/|$)/) - } - }) + await fs + .copy(path.resolve(__dirname, '../packages/playground'), tempDir, { + dereference: false, + filter(file) { + file = file.replace(/\\/g, '/') + return !file.includes('__tests__') && !file.match(/dist(\/|$)/) + } + }) + .catch(async (error) => { + if (error.code === 'EPERM' && error.syscall === 'symlink') { + throw new Error( + '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.' + ) + } else { + throw error + } + }) }