Skip to content

Commit ab95f71

Browse files
committed
move parseTaskAndArguments into the tests as a temporary fix for tests
1 parent 38b2dc1 commit ab95f71

File tree

2 files changed

+32
-35
lines changed

2 files changed

+32
-35
lines changed

v-next/hardhat/src/internal/cli/main.ts

+1-34
Original file line numberDiff line numberDiff line change
@@ -249,39 +249,6 @@ export function parseTask(
249249
return taskOrId;
250250
}
251251

252-
/**
253-
* Parses the task id and its arguments.
254-
*
255-
* @returns The task and its arguments, or an array with the unrecognized task
256-
* id. If no task id is provided, an empty array is returned.
257-
*/
258-
// todo: this function isn't used anymore and needs to be removed
259-
export function parseTaskAndArguments(
260-
cliArguments: string[],
261-
usedCliArguments: boolean[],
262-
hre: HardhatRuntimeEnvironment,
263-
):
264-
| {
265-
task: Task;
266-
taskArguments: TaskArguments;
267-
}
268-
| string[] {
269-
const taskOrId = parseTask(cliArguments, usedCliArguments, hre);
270-
if (Array.isArray(taskOrId)) {
271-
return taskOrId;
272-
}
273-
274-
const task = taskOrId;
275-
276-
const taskArguments = parseTaskArguments(
277-
cliArguments,
278-
usedCliArguments,
279-
task,
280-
);
281-
282-
return { task, taskArguments };
283-
}
284-
285252
function getTaskFromCliArguments(
286253
cliArguments: string[],
287254
usedCliArguments: boolean[],
@@ -341,7 +308,7 @@ function getTaskFromCliArguments(
341308
return task;
342309
}
343310

344-
function parseTaskArguments(
311+
export function parseTaskArguments(
345312
cliArguments: string[],
346313
usedCliArguments: boolean[],
347314
task: Task,

v-next/hardhat/test/internal/cli/main.ts

+31-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { HardhatRuntimeEnvironment } from "@nomicfoundation/hardhat-core/ty
66
import type {
77
NewTaskDefinition,
88
NewTaskDefinitionBuilder,
9+
Task,
10+
TaskArguments,
911
} from "@nomicfoundation/hardhat-core/types/tasks";
1012

1113
import assert from "node:assert/strict";
@@ -27,7 +29,8 @@ import {
2729
main,
2830
parseGlobalOptions,
2931
parseHardhatSpecialArguments,
30-
parseTaskAndArguments,
32+
parseTask,
33+
parseTaskArguments,
3134
} from "../../../src/internal/cli/main.js";
3235
import { resetHardhatRuntimeEnvironmentSingleton } from "../../../src/internal/hre-singleton.js";
3336
import { getHardhatVersion } from "../../../src/internal/utils/package.js";
@@ -465,6 +468,33 @@ For global options help run: hardhat --help`;
465468
});
466469

467470
describe("parseTaskAndArguments", function () {
471+
// This is not an ideal way to test these two functions now that they're split apart,
472+
// but I don't think it's worth the time to refactor all of these tests right now since the logic is the same.
473+
function parseTaskAndArguments(
474+
cliArguments: string[],
475+
usedCliArguments: boolean[],
476+
hreLocal: HardhatRuntimeEnvironment,
477+
):
478+
| {
479+
task: Task;
480+
taskArguments: TaskArguments;
481+
}
482+
| string[] {
483+
const parsedTask = parseTask(cliArguments, usedCliArguments, hreLocal);
484+
if (Array.isArray(parsedTask)) {
485+
return parsedTask;
486+
}
487+
488+
return {
489+
task: parsedTask,
490+
taskArguments: parseTaskArguments(
491+
cliArguments,
492+
usedCliArguments,
493+
parsedTask,
494+
),
495+
};
496+
}
497+
468498
let hre: HardhatRuntimeEnvironment;
469499
let tasks: NewTaskDefinition[];
470500
let subtasks: NewTaskDefinition[];

0 commit comments

Comments
 (0)