checkPlugin: Only create ep_etherpad-lite symlink if missing

This avoids problems if the plugin has a non-peer dependency on
`ep_etherpad-lite`.
This commit is contained in:
Richard Hansen 2022-02-20 17:50:32 -05:00
parent 9ed1e43593
commit f046f0ab81

View file

@ -34,6 +34,7 @@ const path = require('path');
process.chdir(epRootDir); process.chdir(epRootDir);
const pluginPath = await fsp.realpath(`node_modules/${pluginName}`); const pluginPath = await fsp.realpath(`node_modules/${pluginName}`);
console.log(`Plugin directory: ${pluginPath}`); console.log(`Plugin directory: ${pluginPath}`);
const epSrcDir = await fsp.realpath(path.join(epRootDir, 'src'));
const optArgs = process.argv.slice(3); const optArgs = process.argv.slice(3);
const autoPush = optArgs.includes('autopush'); const autoPush = optArgs.includes('autopush');
@ -330,10 +331,14 @@ const path = require('path');
// if autoFix is enabled. // if autoFix is enabled.
const npmInstall = `npm install${autoFix ? '' : ' --no-package-lock'}`; const npmInstall = `npm install${autoFix ? '' : ' --no-package-lock'}`;
execSync(npmInstall, {stdio: 'inherit'}); execSync(npmInstall, {stdio: 'inherit'});
// The ep_etherpad-lite peer dep must be installed last otherwise `npm install` will nuke it. An // Create the ep_etherpad-lite symlink if necessary. This must be done after running `npm install`
// absolute path to etherpad-lite/src is used here so that pluginPath can be a symlink. // because that command nukes the symlink.
execSync( try {
`${npmInstall} --no-save ep_etherpad-lite@file:${__dirname}/../../`, {stdio: 'inherit'}); 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 // linting begins
try { try {
console.log('Linting...'); console.log('Linting...');