Skip to content

Commit 48e970b

Browse files
committed
cleanup
1 parent 16d9a80 commit 48e970b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/changefile/promptForChange.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import prompts from 'prompts';
2-
import { prerelease } from 'semver';
2+
import semver from 'semver';
33
import { ChangeFileInfo, ChangeType } from '../types/ChangeInfo';
44
import { BeachballOptions } from '../types/BeachballOptions';
55
import { isValidChangeType } from '../validation/isValidChangeType';
@@ -28,12 +28,18 @@ export async function promptForChange(params: {
2828

2929
// Get the questions for each package first, in case one package has a validation issue
3030
const packageQuestions: { [pkg: string]: prompts.PromptObject[] } = {};
31+
let hasError = false;
3132
for (const pkg of changedPackages) {
3233
const questions = _getQuestionsForPackage({ pkg, ...params });
33-
if (!questions) {
34-
return; // validation issue
34+
if (questions) {
35+
packageQuestions[pkg] = questions;
36+
} else {
37+
// show all the errors before returning
38+
hasError = true;
3539
}
36-
packageQuestions[pkg] = questions;
40+
}
41+
if (hasError) {
42+
return;
3743
}
3844

3945
// Now prompt for each package
@@ -56,6 +62,7 @@ export async function promptForChange(params: {
5662

5763
/**
5864
* Build the list of questions to ask the user for this package.
65+
* Also validates the options and returns undefined if there's an issue.
5966
* @internal exported for testing
6067
*/
6168
export function _getQuestionsForPackage(params: {
@@ -75,7 +82,7 @@ export function _getQuestionsForPackage(params: {
7582
}
7683

7784
const packageInfo = packageInfos[pkg];
78-
const showPrereleaseOption = !!prerelease(packageInfo.version);
85+
const showPrereleaseOption = !!semver.prerelease(packageInfo.version);
7986
const changeTypeChoices: prompts.Choice[] = [
8087
...(showPrereleaseOption ? [{ value: 'prerelease', title: ' Prerelease - bump prerelease version' }] : []),
8188
{ value: 'patch', title: ' Patch - bug fixes; no API changes.' },

0 commit comments

Comments
 (0)