Skip to content

Commit

Permalink
Merge branch 'fix-remapped-root-bug' into fix-automatic-sender
Browse files Browse the repository at this point in the history
  • Loading branch information
alcuadrado authored Oct 27, 2024
2 parents 3392b5a + 62ac5f0 commit 07b9706
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 151 deletions.
59 changes: 2 additions & 57 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion v-next/example-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@types/node": "^20.14.9",
"mocha": "^10.0.0",
"prettier": "3.2.5",
"rimraf": "^6.0.1",
"rimraf": "^5.0.5",
"typescript": "~5.5.0",
"viem": "^2.21.17",
"forge-std": "foundry-rs/forge-std#v1.9.4"
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion v-next/hardhat-mocha-test-runner/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Hardhat Mocha plugin", () => {

const hre = await createHardhatRuntimeEnvironment(hardhatConfig.default);

const result = await hre.tasks.getTask("test").run({});
const result = await hre.tasks.getTask(["test", "mocha"]).run({});

assert.equal(result, 0);
});
Expand Down
2 changes: 1 addition & 1 deletion v-next/hardhat/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ process.setSourceMapsEnabled(true);
// eslint-disable-next-line no-restricted-syntax -- Allow top-level await here
const { main } = await import("./internal/cli/main.js");

main(process.argv.slice(2), undefined, true).catch(() => {
main(process.argv.slice(2), { registerTsx: true }).catch(() => {
process.exitCode = 1;
});
5 changes: 5 additions & 0 deletions v-next/hardhat/src/internal/builtin-plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ import networkManager from "./network-manager/index.js";
import run from "./run/index.js";
import solidity from "./solidity/index.js";
import solidityTest from "./solidity-test/index.js";
import test from "./test/index.js";

// Note: When importing a plugin, you have to export its types, so that its
// type extensions, if any, also get loaded.
export type * from "./artifacts/index.js";
export type * from "./solidity/index.js";
export type * from "./test/index.js";
export type * from "./solidity-test/index.js";
export type * from "./network-manager/index.js";
export type * from "./clean/index.js";
export type * from "./console/index.js";
export type * from "./run/index.js";

// This array should be kept in order, respecting the dependencies between the
// plugins.
export const builtinPlugins: HardhatPlugin[] = [
artifacts,
solidity,
test,
solidityTest,
networkManager,
clean,
Expand Down
18 changes: 14 additions & 4 deletions v-next/hardhat/src/internal/cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ import { getHelpString } from "./helpers/getHelpString.js";
import { ensureTelemetryConsent } from "./telemetry/telemetry-permissions.js";
import { printVersionMessage } from "./version.js";

export interface MainOptions {
print?: (message: string) => void;
registerTsx?: true;
rethrowErrors?: true;
}

export async function main(
cliArguments: string[],
print: (message: string) => void = console.log,
registerTsx = false,
options: MainOptions = {},
): Promise<void> {
const print = options.print ?? console.log;

const log = debug("hardhat:core:cli:main");

let builtinGlobalOptions;
Expand Down Expand Up @@ -80,8 +87,7 @@ export async function main(

const projectRoot = await resolveProjectRoot(configPath);

// Register tsx
if (registerTsx) {
if (options.registerTsx) {
register();
}

Expand Down Expand Up @@ -166,6 +172,10 @@ export async function main(
await task.run(taskArguments);
} catch (error) {
printErrorMessages(error, builtinGlobalOptions?.showStackTraces);

if (options.rethrowErrors) {
throw error;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { HardhatUserConfig } from "../../../../../src/config.js";

import { task } from "../../../../../src/config.js";

const customTask = task("test", "subtask")
const customTask = task("test-task", "description")
.setAction(async () => {})
.addOption({
name: "opt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { task } from "@ignored/hardhat-vnext/config";

export default {
tasks: [
task("test", "Prints a test")
task("test-task", "Prints a test")
.setAction(async () => {
console.log("test!");
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hre from "@ignored/hardhat-vnext";

if (!hre.tasks.rootTasks.has("test")) {
if (!hre.tasks.rootTasks.has("test-task")) {
throw new Error("test task not found");
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { task } from "@ignored/hardhat-vnext/config";

const config: HardhatUserConfig = {
tasks: [
task("test", "Prints a test")
task("test-task", "Prints a test")
.setAction(async () => {
console.log("test!");
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import maybeHre from "@ignored/hardhat-vnext";

if (!maybeHre.tasks.rootTasks.has("test")) {
if (!maybeHre.tasks.rootTasks.has("test-task")) {
throw new Error("test task not found");
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("console/task-action", function () {
{
commands: ['await import("./scripts/non-existent.js");', ".exit"],
history: "",
noCompile: false,
noCompile: true,
options,
},
hre,
Expand All @@ -61,7 +61,7 @@ describe("console/task-action", function () {
{
commands: [".help", 'await import("./scripts/success.js");', ".exit"],
history: "",
noCompile: false,
noCompile: true,
options,
},
hre,
Expand All @@ -74,7 +74,7 @@ describe("console/task-action", function () {
{
commands: ['await import("./scripts/throws.js");', ".exit"],
history: "",
noCompile: false,
noCompile: true,
options,
},
hre,
Expand All @@ -91,7 +91,7 @@ describe("console/task-action", function () {
{
commands: ['await import("./scripts/non-existent.ts");', ".exit"],
history: "",
noCompile: false,
noCompile: true,
options,
},
hre,
Expand All @@ -104,7 +104,7 @@ describe("console/task-action", function () {
{
commands: ['await import("./scripts/success.ts");', ".exit"],
history: "",
noCompile: false,
noCompile: true,
options,
},
hre,
Expand All @@ -117,7 +117,7 @@ describe("console/task-action", function () {
{
commands: ['await import("./scripts/throws.ts");', ".exit"],
history: "",
noCompile: false,
noCompile: true,
options,
},
hre,
Expand All @@ -132,7 +132,7 @@ describe("console/task-action", function () {
{
commands: ["console.log(hre);", ".exit"],
history: "",
noCompile: false,
noCompile: true,
options,
},
hre,
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("console/task-action", function () {
{
commands: [".help", ".exit"],
history,
noCompile: false,
noCompile: true,
options,
},
hre,
Expand Down
Loading

0 comments on commit 07b9706

Please sign in to comment.