Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support semantic-release higher than version 19 #235

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
const requireReload = require('require-reload');

const reload = requireReload(require);

// The @semantic-release/npm plugin maintains
// some state at the module level to decide where to
// store its .npmrc file.
// Because of this, we have to monkey around a bit with
// Node's require cache in order to create multiple copies
// of the module in order to use it with different configurations.
const registryPlugins = {};
function getChildPlugin(registryName) {
async function getChildPlugin(registryName) {
let plugin = registryPlugins[registryName];
if (!plugin) {
plugin = reload('@semantic-release/npm');
plugin = await import('@semantic-release/npm');
registryPlugins[registryName] = plugin;
}

Expand All @@ -24,7 +20,7 @@ function createCallbackWrapper(callbackName) {
for (const [registryName, childConfig] of Object.entries(
registries || {},
)) {
const callback = getChildPlugin(registryName)[callbackName];
const callback = (await getChildPlugin(registryName))[callbackName];
if (!callback) {
return;
}
Expand Down Expand Up @@ -61,7 +57,7 @@ function createCallbackWrapper(callbackName) {

const callbackNames = ['verify', 'prepare', 'publish', 'success', 'fail'];

module.exports = Object.assign(
export default Object.assign(
{},
...callbackNames.map(name => ({ [name]: createCallbackWrapper(name) })),
);
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"files": [
"index.js"
],
"type": "module",
"publishConfig": {
"access": "public"
},
Expand All @@ -28,10 +29,9 @@
"semantic-release": "^22.0.0"
},
"dependencies": {
"@semantic-release/npm": "^11.0.0",
"require-reload": "^0.2.2"
"@semantic-release/npm": "^11.0.0"
},
"peerDependencies": {
"semantic-release": "^19.x"
"semantic-release": ">= 19"
}
}
Loading