Skip to content

Commit f749378

Browse files
committed
Rename function for clarity
1 parent d4c5fdd commit f749378

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

v-next/hardhat/src/internal/cli/helpers/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function parseGlobalOptions(
1717
globalOptionDefinitions: GlobalOptionDefinitions,
1818
): ArgumentDescriptor[] {
1919
return [...globalOptionDefinitions].map(([, { option }]) => ({
20-
name: formatOptionName(option.name),
20+
name: toCommandLineOption(option.name),
2121
description: option.description,
2222
}));
2323
}
@@ -64,7 +64,7 @@ export function parseOptions(task: Task): {
6464

6565
for (const [optionName, option] of task.options) {
6666
options.push({
67-
name: formatOptionName(optionName),
67+
name: toCommandLineOption(optionName),
6868
description: option.description,
6969
type: option.type,
7070
});
@@ -81,8 +81,8 @@ export function parseOptions(task: Task): {
8181
return { options, positionalArguments };
8282
}
8383

84-
export function formatOptionName(str: string): string {
85-
return `--${camelToKebabCase(str)}`;
84+
export function toCommandLineOption(optionName: string): string {
85+
return `--${camelToKebabCase(optionName)}`;
8686
}
8787

8888
export function getLongestNameLength(tasks: Array<{ name: string }>): number {

v-next/hardhat/test/internal/cli/helpers/utils.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
parseTasks,
1010
parseSubtasks,
1111
parseOptions,
12-
formatOptionName,
12+
toCommandLineOption,
1313
getLongestNameLength,
1414
getSection,
1515
getUsageString,
@@ -179,10 +179,11 @@ describe("utils", function () {
179179
});
180180
});
181181

182-
describe("formatOptionName", function () {
183-
it("should format option names", function () {
184-
assert.equal(formatOptionName("option"), "--option");
185-
assert.equal(formatOptionName("anotherOption"), "--another-option");
182+
describe("toCommandLineOption", function () {
183+
it("should convert a camelCase option name to a kebab-case command line option", function () {
184+
assert.equal(toCommandLineOption("option"), "--option");
185+
assert.equal(toCommandLineOption("anotherOption"), "--another-option");
186+
assert.equal(toCommandLineOption("anotherOption1"), "--another-option-1");
186187
});
187188
});
188189

0 commit comments

Comments
 (0)