Skip to content

Commit

Permalink
feat: checking for extends options to be type of string
Browse files Browse the repository at this point in the history
  • Loading branch information
juancarlosjr97 committed Dec 14, 2024
1 parent 03f94dd commit 7b19d20
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const runTasks = async (opts, di) => {
Object.assign(container, di);
container.config = container.config || new Config(opts);

if ('extends' in container.config.options) {
if (typeof container.config.options?.extends === 'string') {
/**
* If the configuration has an 'extends' property, fetch the remote configuration
* and merge it into the local configuration options.
Expand Down
25 changes: 25 additions & 0 deletions test/tasks.interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ test.serial('should run tasks using extended configuration', async t => {

const { name, latestVersion, version } = await runTasks({}, container);

t.is(fetchStub.callCount, 1);

const commands = _.flatten(exec.args).filter(arg => typeof arg === 'string' && arg.startsWith('echo'));

t.true(commands.includes(validationExtendedConfiguration));
Expand All @@ -124,6 +126,29 @@ test.serial('should run tasks using extended configuration', async t => {
fetchStub.restore();
});

test.serial('should run tasks not using extended configuration as it is not a string', async t => {
sh.mv('.git', 'foo');

const fetchStub = sandbox.stub(global, 'fetch');

const config = {
$schema: 'https://unpkg.com/release-it@17/schema/release-it.json',
extends: false
};

const container = getContainer(config);

const { name, latestVersion, version } = await runTasks({}, container);

t.is(fetchStub.callCount, 0);

t.is(version, '0.0.1');
t.true(log.obtrusive.firstCall.args[0].includes(`release ${name} (currently at ${latestVersion})`));
t.regex(log.log.lastCall.args[0], /Done \(in [0-9]+s\.\)/);

fetchStub.restore();
});

test.serial('should not run hooks for disabled release-cycle methods', async t => {
const hooks = getHooks(['version', 'git', 'github', 'gitlab', 'npm']);

Expand Down

0 comments on commit 7b19d20

Please sign in to comment.