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

fix: Accept undefined options and commits array #12

Merged
merged 1 commit into from Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/index.js
Expand Up @@ -15,7 +15,7 @@ const DEFAULT_RELEASE_RULES = require('./default/release-rules');
/**
* Determine the type of release to create based on a list of commits.
*
* @param {Object} pluginConfig semantic-release configuration
* @param {Object} [pluginConfig={}] semantic-release configuration
* @param {string} pluginConfig.preset conventional-changelog preset ('angular', 'atom', 'codemirror', 'ember', 'eslint', 'express', 'jquery', 'jscs', 'jshint')
* @param {string} pluginConfig.config requierable npm package with a custom conventional-changelog preset
* @param {string|Array} pluginConfig.releaseRules a string to load an external module or an `Array` of rules.
Expand All @@ -24,7 +24,7 @@ const DEFAULT_RELEASE_RULES = require('./default/release-rules');
* @param {Array} options.commits array of commits
* @param {commitAnalyzerCallback} callback The callback called with the release type.
*/
module.exports = async (pluginConfig, {commits}, callback) => {
module.exports = async (pluginConfig = {}, {commits}, callback) => {
try {
const releaseRules = loadReleaseRules(pluginConfig);
const config = await loadParserConfig(pluginConfig);
Expand Down
7 changes: 7 additions & 0 deletions test/integration.test.js
Expand Up @@ -187,3 +187,10 @@ test('Handle error in "conventional-changelog-parser" and wrap in "SemanticRelea

t.true(error instanceof SemanticReleaseError);
});

test('Accept an undefined "pluginConfig"', async t => {
const commits = [{message: 'fix(scope1): First fix'}, {message: 'feat(scope2): Second feature'}];
const releaseType = await pify(commitAnalyzer)(undefined, {commits});

t.is(releaseType, 'minor');
});