Compare commits

..
2 Commits
4 changed files with 53 additions and 3 deletions
+3 -1
View File
@@ -23,4 +23,6 @@ npx is bundled with npm >= 5.4, or available via npm. More info: npm.im/npx`
}
// node 8+ from this point on
require('../src')();
require('../src')().catch(() => {
process.exit(1);
});
+1 -1
View File
@@ -36,7 +36,7 @@ const normalize = (pluginConfig, fallback) => {
return relative(pluginConfig.path).bind(null, pluginConfig);
}
return require(fallback).bind(null, pluginConfig);
return require(fallback).bind(null, pluginConfig || {});
};
module.exports.normalize = normalize;
+23
View File
@@ -207,3 +207,26 @@ test.serial('Release versions from a packed git repository, using tags to determ
t.is(version, '1.0.1');
t.log(`+ released ${version}`);
});
test.serial('Exit with 1 in a plugin is not found', async t => {
// Environment variables used with cli
const env = {
CI: true,
npm_config_registry: uri,
GH_TOKEN: 'github_token',
NPM_OLD_TOKEN: 'aW50ZWdyYXRpb246c3VjaHNlY3VyZQ==',
NPM_EMAIL: 'integration@test.com',
};
// Create a git repository, set the current working directory at the root of the repo
t.log('Create git repository');
await gitRepo();
await writeJson('./package.json', {
name: 'test-module-3',
version: '0.0.0-dev',
repository: {url: 'git+https://github.com/semantic-release/test-module-4'},
release: {analyzeCommits: 'non-existing-path'},
});
const {code} = await t.throws(execa(require.resolve('../bin/semantic-release'), ['pre'], {env}));
t.is(code, 1);
});
+26 -1
View File
@@ -1,3 +1,4 @@
import {promisify} from 'util';
import test from 'ava';
import plugins from '../src/lib/plugins';
@@ -69,10 +70,34 @@ test('Normalize and load plugin from object', t => {
t.is(typeof plugin, 'function');
});
test('load from fallback', t => {
test('Load from fallback', t => {
// Call the normalize function with a fallback
const plugin = plugins.normalize(null, '../lib/plugin-noop');
// Verify the fallback plugin is loaded
t.is(typeof plugin, 'function');
});
test('Always pass a defined "pluginConfig" for plugin defined with string', async t => {
// Call the normalize function with the path of a plugin that returns its config
const plugin = plugins.normalize('./test/fixtures/plugin-result-config');
const pluginResult = await promisify(plugin)({});
t.deepEqual(pluginResult.pluginConfig, {});
});
test('Always pass a defined "pluginConfig" for plugin defined with path', async t => {
// Call the normalize function with the path of a plugin that returns its config
const plugin = plugins.normalize({path: './test/fixtures/plugin-result-config'});
const pluginResult = await promisify(plugin)({});
t.deepEqual(pluginResult.pluginConfig, {path: './test/fixtures/plugin-result-config'});
});
test('Always pass a defined "pluginConfig" for fallback plugin', async t => {
// Call the normalize function with the path of a plugin that returns its config
const plugin = plugins.normalize(null, '../../test/fixtures/plugin-result-config');
const pluginResult = await promisify(plugin)({});
t.deepEqual(pluginResult.pluginConfig, {});
});