From f046f0ab8119130c15d45ba41fe0e235fc859d19 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 20 Feb 2022 17:50:32 -0500 Subject: [PATCH] checkPlugin: Only create `ep_etherpad-lite` symlink if missing This avoids problems if the plugin has a non-peer dependency on `ep_etherpad-lite`. --- src/bin/plugins/checkPlugin.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bin/plugins/checkPlugin.js b/src/bin/plugins/checkPlugin.js index e6591bd31..8be9316cb 100755 --- a/src/bin/plugins/checkPlugin.js +++ b/src/bin/plugins/checkPlugin.js @@ -34,6 +34,7 @@ const path = require('path'); process.chdir(epRootDir); const pluginPath = await fsp.realpath(`node_modules/${pluginName}`); console.log(`Plugin directory: ${pluginPath}`); + const epSrcDir = await fsp.realpath(path.join(epRootDir, 'src')); const optArgs = process.argv.slice(3); const autoPush = optArgs.includes('autopush'); @@ -330,10 +331,14 @@ const path = require('path'); // if autoFix is enabled. const npmInstall = `npm install${autoFix ? '' : ' --no-package-lock'}`; execSync(npmInstall, {stdio: 'inherit'}); - // The ep_etherpad-lite peer dep must be installed last otherwise `npm install` will nuke it. An - // absolute path to etherpad-lite/src is used here so that pluginPath can be a symlink. - execSync( - `${npmInstall} --no-save ep_etherpad-lite@file:${__dirname}/../../`, {stdio: 'inherit'}); + // Create the ep_etherpad-lite symlink if necessary. This must be done after running `npm install` + // because that command nukes the symlink. + try { + const d = await fsp.realpath(path.join(pluginPath, 'node_modules/ep_etherpad-lite')); + assert.equal(d, epSrcDir); + } catch (err) { + execSync(`${npmInstall} --no-save ep_etherpad-lite@file:${epSrcDir}`, {stdio: 'inherit'}); + } // linting begins try { console.log('Linting...');