|
1 | | -// Proxy all methods on the commit analyzer exports |
2 | | -module.exports = new Proxy(require("@semantic-release/commit-analyzer"), { |
3 | | - get (target, property, receiver) { |
4 | | - // If looking for the analyze commits plugin lifecycle method, return a proxy |
5 | | - if (property === "analyzeCommits") { |
6 | | - return new Proxy(target.analyzeCommits, { |
7 | | - async apply (target, thisArgument, argumentsList) { |
8 | | - // Await for the analysis from the proxy target to complete |
9 | | - const result = await Reflect.apply(target, thisArgument, argumentsList); |
10 | | - // It's gonna make a release |
11 | | - if (result != null) return result; |
12 | | - // Nullish means it's not making a release, let's throw a fit! |
13 | | - throw new Error("There are no relevant changes and you are using commit-analyzer-fail-on-no-release."); |
14 | | - }, |
15 | | - }); |
16 | | - } |
17 | | - // Otherwise just return whatever it would've anyways |
18 | | - return Reflect.get(target, property, receiver); |
| 1 | +// This file replaces an existing export by exporting twice |
| 2 | +/* eslint-disable import/export */ |
| 3 | +import {analyzeCommits as originalAnalyzeCommits} from "@semantic-release/commit-analyzer"; |
| 4 | + |
| 5 | +// Re-export all the commit analyzer exports in case they add another export in the future |
| 6 | +export * from "@semantic-release/commit-analyzer"; |
| 7 | + |
| 8 | +// Proxy analyzeCommits so we can intercept the result and throw an error |
| 9 | +export const analyzeCommits = new Proxy(originalAnalyzeCommits, { |
| 10 | + async apply (target, thisArgument, argumentsList) { |
| 11 | + // Await for the analysis from the proxy target to complete |
| 12 | + const result = await Reflect.apply(target, thisArgument, argumentsList); |
| 13 | + // It's gonna make a release |
| 14 | + if (result != null) return result; |
| 15 | + // Nullish means it's not making a release, let's throw a fit! |
| 16 | + throw new Error("There are no relevant changes and you are using commit-analyzer-fail-on-no-release."); |
19 | 17 | }, |
20 | 18 | }); |
0 commit comments