Skip to content

Commit 874883d

Browse files
committedJul 12, 2024·
Make resolveProjectRoot simpler
·
1 parent f972ba6 commit 874883d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
 

‎v-next/core/src/internal/hre.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { HookManagerImplementation } from "./hook-manager.js";
2626
import { resolvePluginList } from "./plugins/resolve-plugin-list.js";
2727
import { TaskManagerImplementation } from "./tasks/task-manager.js";
2828
import { UserInterruptionManagerImplementation } from "./user-interruptions.js";
29+
import { getRealPath } from "@ignored/hardhat-vnext-utils/fs";
2930

3031
export class HardhatRuntimeEnvironmentImplementation
3132
implements HardhatRuntimeEnvironment
@@ -142,12 +143,17 @@ export class HardhatRuntimeEnvironmentImplementation
142143
}
143144

144145
/**
145-
* Resolves the project root of a Hardhat project.
146+
* Resolves the project root of a Hardhat project based on the config file or
147+
* another path within the project. If not provided, it will be resolved from
148+
* the current working directory.
149+
*
150+
* @param absolutePathWithinProject An absolute path within the project, usually
151+
* the config file.
146152
*/
147153
export async function resolveProjectRoot(
148-
projectRoot: string | undefined,
154+
absolutePathWithinProject: string | undefined,
149155
): Promise<string> {
150-
return findClosestPackageRoot(projectRoot ?? process.cwd());
156+
return findClosestPackageRoot(absolutePathWithinProject ?? process.cwd());
151157
}
152158

153159
async function runUserConfigExtensions(

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
assertHardhatInvariant,
2727
} from "@ignored/hardhat-vnext-errors";
2828
import { isCi } from "@ignored/hardhat-vnext-utils/ci";
29+
import { getRealPath } from "@ignored/hardhat-vnext-utils/fs";
2930
import { kebabToCamelCase } from "@ignored/hardhat-vnext-utils/string";
3031

3132
import { resolveHardhatConfigPath } from "../../config.js";
@@ -70,7 +71,7 @@ export async function main(
7071
}
7172

7273
const projectRoot = await resolveProjectRoot(
73-
builtinGlobalOptions.configPath,
74+
await getRealPath(builtinGlobalOptions.configPath),
7475
);
7576

7677
const userConfig = await importUserConfig(builtinGlobalOptions.configPath);

0 commit comments

Comments
 (0)
Please sign in to comment.