Skip to content

Commit

Permalink
Improve legacy module resolution for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Aug 1, 2021
1 parent 134d27e commit c97fc2b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/plugin/factory.js
Expand Up @@ -8,8 +8,6 @@ import GitLab from './gitlab/GitLab.js';
import GitHub from './github/GitHub.js';
import npm from './npm/npm.js';

const requireCwd = createRequire(process.cwd());

const debug = _debug('release-it:plugins');

const pluginNames = ['npm', 'git', 'github', 'gitlab', 'version'];
Expand All @@ -32,8 +30,9 @@ const load = async pluginName => {
const module = await import(path.join(process.cwd(), pluginName));
plugin = module.default;
} catch (err) {
// In some cases or tests we might need to support "directory imports" (legacy `require`)
const module = await import(requireCwd.resolve(path.join(process.cwd(), pluginName)));
// In some cases or tests we might need to support legacy `require.resolve`
const require = createRequire(process.cwd());
const module = await import(require.resolve(pluginName, { paths: [process.cwd()] }));
plugin = module.default;
}
}
Expand Down

0 comments on commit c97fc2b

Please sign in to comment.