Skip to content

Commit a064464

Browse files
authored
fix: support invocation without semantic-release (#139)
1 parent 507e732 commit a064464

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/utils.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
const getConfig = require('semantic-release/lib/get-config');
2-
const getLogger = require('semantic-release/lib/get-logger');
1+
let getConfig = null,
2+
getLogger = null;
3+
try {
4+
getConfig = require('semantic-release/lib/get-config');
5+
getLogger = require('semantic-release/lib/get-logger');
6+
} catch (err) {
7+
if (err.code !== 'MODULE_NOT_FOUND') throw err;
8+
}
39
const { Writable } = require('stream');
410

511
const devNull = () =>
@@ -15,6 +21,10 @@ const devNull = () =>
1521
* @return {Promise<Object>} The configuration object, which includes an options field among others.
1622
*/
1723
async function getReleaseConfig() {
24+
if (!getLogger || !getConfig) {
25+
throw new Error('cannot get release config - semantic-release not available');
26+
}
27+
1828
const context = {
1929
cwd: process.cwd(),
2030
// The logger logs a bunch of unhelpful stuff when loading plugins, and we're only loading

0 commit comments

Comments
 (0)