Skip to content

Commit 06a142c

Browse files
committed
Fix --release-draft-only failing with version check error
Fixes #781
1 parent 6d4b88e commit 06a142c

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

source/ui.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,15 @@ const ui = async ({packageManager, ...options}, {package_, rootDirectory}) => {
221221
}
222222
}
223223

224+
if (options.releaseDraftOnly) {
225+
return {
226+
...options,
227+
confirm: true,
228+
repoUrl,
229+
generateReleaseNotes,
230+
};
231+
}
232+
224233
// Non-interactive mode - return before prompting
225234
// But if it's a prerelease without a tag, we need to prompt for the tag
226235
if (options.version) {

test/ui/prompts/version.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,37 @@ test('handles numeric prerelease identifiers', testUi, {
199199
// Should transition from numeric to string identifier
200200
t.is(version.toString(), '1.0.0-beta.0');
201201
});
202+
203+
test('releaseDraftOnly does not throw on current version', async t => {
204+
const {ui} = await mockInquirer({
205+
t, answers: {}, mocks: {
206+
'./util.js': {
207+
getPreReleasePrefix: sinon.stub().resolves(''),
208+
},
209+
'./git-util.js': {
210+
previousTagOrFirstCommit: sinon.stub().resolves('v1.0.0'),
211+
commitLogFromRevision: sinon.stub().resolves(''),
212+
},
213+
execa: {
214+
execa: sinon.stub().resolves({stdout: 'https://registry.npmjs.org/'}),
215+
},
216+
},
217+
});
218+
219+
const results = await ui({
220+
packageManager,
221+
runPublish: false,
222+
availability: {},
223+
releaseDraftOnly: true,
224+
version: '1.0.0',
225+
}, {
226+
package_: {
227+
name: 'foo',
228+
version: '1.0.0',
229+
repository: {url: 'https://github.com/foo/bar'},
230+
},
231+
});
232+
233+
t.true(results.confirm);
234+
t.is(results.version, '1.0.0');
235+
});

0 commit comments

Comments
 (0)