From 5c79092fcd0761ea27a5dd82ec5661409237dcde Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Tue, 16 Nov 2021 16:07:17 +0100 Subject: [PATCH] test(Plugins): Ensure to not leave broken symlinks in a setup fixture Otherwise it leaves a broken symlink of which copying crashes `fse.copy` --- test/fixtures/programmatic/curated-plugins/_setup.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/fixtures/programmatic/curated-plugins/_setup.js b/test/fixtures/programmatic/curated-plugins/_setup.js index fb374507b1c..f075ebc2aa8 100644 --- a/test/fixtures/programmatic/curated-plugins/_setup.js +++ b/test/fixtures/programmatic/curated-plugins/_setup.js @@ -3,7 +3,12 @@ const path = require('path'); const fsp = require('fs').promises; -const slsDependencyDir = path.resolve(__dirname, 'node_modules/serverless'); +const nodeModulesDir = path.resolve(__dirname, 'node_modules'); // Ensure to remove "serverless" installed as peer-dependency to avoid local fallback -module.exports = async () => fsp.rm(slsDependencyDir, { recursive: true, force: true }); +module.exports = async () => + Promise.all([ + fsp.rm(path.resolve(nodeModulesDir, 'serverless'), { recursive: true, force: true }), + fsp.unlink(path.resolve(nodeModulesDir, '.bin/serverless')).catch(() => {}), + fsp.unlink(path.resolve(nodeModulesDir, '.bin/sls')).catch(() => {}), + ]);