Skip to content

Commit cdd3f2e

Browse files
authored
Address code review: add config conflict error and camelCase rejection test
Agent-Logs-Url: https://github.com/microsoft/beachball/sessions/b10c3147-797f-4524-a56d-1f2537833d47
1 parent f9c491f commit cdd3f2e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/__functional__/options/getCliOptions.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ describe('getCliOptions', () => {
116116
});
117117
});
118118

119+
it('rejects camelCase form of multi-word options', () => {
120+
expect(() => getCliOptionsTest(['--gitTags'])).toThrow();
121+
expect(() => getCliOptionsTest(['--dependentChangeType', 'patch'])).toThrow();
122+
expect(() => getCliOptionsTest(['--disallowedChangeTypes', 'major'])).toThrow();
123+
});
124+
119125
it('parses short option aliases', () => {
120126
const options = getCliOptionsTest(['publish', '-t', 'test', '-r', 'http://whatever', '-y']);
121127
expect(options).toEqual({ ...defaults, command: 'publish', tag: 'test', registry: 'http://whatever', yes: true });

src/options/getCliOptions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ export function getCliOptions(processOrArgv: ProcessInfo | string[]): ParsedOpti
153153
};
154154

155155
// Handle --config as alias for --config-path
156-
if (commanderOpts.config !== undefined && commanderOpts.configPath === undefined) {
156+
if (commanderOpts.config !== undefined) {
157+
if (commanderOpts.configPath !== undefined) {
158+
throw new Error('Cannot specify both --config and --config-path');
159+
}
157160
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
158161
commanderOpts.configPath = commanderOpts.config;
159162
}

0 commit comments

Comments
 (0)