Skip to content

Commit

Permalink
fix: Load preset/config if semantic-release run as global install
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Oct 1, 2017
1 parent 1be7cac commit dfb6c22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/load/parser-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const importCwd = require('import-cwd');
const importFrom = require('import-from');
const pify = require('pify');
const {mergeWith} = require('lodash');
const SemanticReleaseError = require('@semantic-release/error');
Expand All @@ -16,14 +16,15 @@ module.exports = async ({preset, config, parserOpts}) => {
let loadedConfig = {};

if (preset) {
const presetPackage = `conventional-changelog-${preset.toLowerCase()}`;
try {
loadedConfig = importCwd(`conventional-changelog-${preset.toLowerCase()}`);
loadedConfig = importFrom.silent(__dirname, presetPackage) || importFrom(process.cwd(), presetPackage);
} catch (err) {
throw new SemanticReleaseError(`Preset: "${preset}" does not exist: ${err.message}`, err.code);
}
} else if (config) {
try {
loadedConfig = importCwd(config);
loadedConfig = importFrom.silent(__dirname, config) || importFrom(process.cwd(), config);
} catch (err) {
throw new SemanticReleaseError(`Config: "${config}" does not exist: ${err.message}`, err.code);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@semantic-release/error": "^2.0.0",
"conventional-changelog-angular": "^1.4.0",
"conventional-commits-parser": "^2.0.0",
"import-cwd": "^2.1.0",
"import-from": "^2.1.0",
"lodash": "^4.17.4",
"pify": "^3.0.0"
},
Expand Down

0 comments on commit dfb6c22

Please sign in to comment.