Skip to content

Commit 40c19b5

Browse files
committed
Upgrade find-up (Thanks @kiriyaga-txfusion!)
1 parent f1f10f2 commit 40c19b5

File tree

9 files changed

+23
-77
lines changed

9 files changed

+23
-77
lines changed

packages/hardhat-core/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"@types/chai-as-promised": "^7.1.3",
6767
"@types/ci-info": "^2.0.0",
6868
"@types/debug": "^4.1.4",
69-
"@types/find-up": "^2.1.1",
7069
"@types/fs-extra": "^5.1.0",
7170
"@types/keccak": "^3.0.1",
7271
"@types/lodash": "^4.14.123",
@@ -120,7 +119,7 @@
120119
"env-paths": "^2.2.0",
121120
"ethereum-cryptography": "^1.0.3",
122121
"ethereumjs-abi": "^0.6.8",
123-
"find-up": "^2.1.0",
122+
"find-up": "^5.0.0",
124123
"fp-ts": "1.19.3",
125124
"fs-extra": "^7.0.1",
126125
"immutable": "^4.0.0-rc.12",

packages/hardhat-core/src/internal/cli/autocomplete.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ function getTaskFromTaskDefinition(taskDef: TaskDefinition): Task {
307307
function getProjectId(): string | undefined {
308308
const packageJsonPath = findup.sync("package.json");
309309

310-
if (packageJsonPath === null) {
310+
if (packageJsonPath === undefined) {
311311
return undefined;
312312
}
313313

packages/hardhat-core/src/internal/core/config/config-loading.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export function analyzeModuleNotFoundError(error: any, configPath: string) {
198198

199199
const packageJsonPath = findClosestPackageJson(throwingFile);
200200

201-
if (packageJsonPath === null) {
201+
if (packageJsonPath === undefined) {
202202
return;
203203
}
204204

packages/hardhat-core/src/internal/core/project-structure.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,31 @@ const CTS_CONFIG_FILENAME = "hardhat.config.cts";
1414

1515
export function isCwdInsideProject() {
1616
return (
17-
findUp.sync(TS_CONFIG_FILENAME) !== null ||
18-
findUp.sync(CTS_CONFIG_FILENAME) !== null ||
19-
findUp.sync(CJS_CONFIG_FILENAME) !== null ||
20-
findUp.sync(JS_CONFIG_FILENAME) !== null
17+
findUp.sync(TS_CONFIG_FILENAME) !== undefined ||
18+
findUp.sync(CTS_CONFIG_FILENAME) !== undefined ||
19+
findUp.sync(CJS_CONFIG_FILENAME) !== undefined ||
20+
findUp.sync(JS_CONFIG_FILENAME) !== undefined
2121
);
2222
}
2323

2424
export function getUserConfigPath() {
2525
const tsConfigPath = findUp.sync(TS_CONFIG_FILENAME);
26-
if (tsConfigPath !== null) {
26+
if (tsConfigPath !== undefined) {
2727
return tsConfigPath;
2828
}
2929

3030
const ctsConfigPath = findUp.sync(CTS_CONFIG_FILENAME);
31-
if (ctsConfigPath !== null) {
31+
if (ctsConfigPath !== undefined) {
3232
return ctsConfigPath;
3333
}
3434

3535
const cjsConfigPath = findUp.sync(CJS_CONFIG_FILENAME);
36-
if (cjsConfigPath !== null) {
36+
if (cjsConfigPath !== undefined) {
3737
return cjsConfigPath;
3838
}
3939

4040
const pathToConfigFile = findUp.sync(JS_CONFIG_FILENAME);
41-
if (pathToConfigFile === null) {
41+
if (pathToConfigFile === undefined) {
4242
throw new HardhatError(ERRORS.GENERAL.NOT_INSIDE_PROJECT);
4343
}
4444

packages/hardhat-core/src/internal/sentry/anonymizer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class Anonymizer {
5959
if (filename === this._configPath) {
6060
const packageJsonPath = this._getFilePackageJsonPath(filename);
6161

62-
if (packageJsonPath === null) {
62+
if (packageJsonPath === undefined) {
6363
// if we can't find a package.json, we just return the basename
6464
return {
6565
anonymizedFilename: path.basename(filename),
@@ -163,7 +163,7 @@ export class Anonymizer {
163163
return false;
164164
}
165165

166-
protected _getFilePackageJsonPath(filename: string): string | null {
166+
protected _getFilePackageJsonPath(filename: string): string | undefined {
167167
return findup.sync("package.json", {
168168
cwd: path.dirname(filename),
169169
});

packages/hardhat-core/src/internal/util/caller-package.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import findup from "find-up";
22
import path from "path";
33

4-
function findClosestPackageJson(file: string): string | null {
4+
function findClosestPackageJson(file: string): string | undefined {
55
return findup.sync("package.json", { cwd: path.dirname(file) });
66
}
77

@@ -35,7 +35,7 @@ export function getClosestCallerPackage(): string | undefined {
3535
continue;
3636
}
3737

38-
if (callerPackage === null) {
38+
if (callerPackage === undefined) {
3939
return undefined;
4040
}
4141

packages/hardhat-core/src/internal/util/packageInfo.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ export interface PackageJson {
2323
};
2424
}
2525

26-
export function findClosestPackageJson(file: string): string | null {
26+
export function findClosestPackageJson(file: string): string | undefined {
2727
return findup.sync("package.json", { cwd: path.dirname(file) });
2828
}
2929

3030
export async function getPackageName(file: string): Promise<string> {
3131
const packageJsonPath = findClosestPackageJson(file);
32-
if (packageJsonPath !== null && packageJsonPath !== "") {
32+
if (packageJsonPath !== undefined && packageJsonPath !== "") {
3333
const packageJson: PackageJson = await fsExtra.readJSON(packageJsonPath);
3434
return packageJson.name;
3535
}
@@ -45,7 +45,7 @@ export function getHardhatVersion(): string {
4545
const packageJsonPath = findClosestPackageJson(__filename);
4646

4747
assertHardhatInvariant(
48-
packageJsonPath !== null,
48+
packageJsonPath !== undefined,
4949
"There should be a package.json in hardhat-core's root directory"
5050
);
5151

@@ -60,7 +60,7 @@ export function getProjectPackageJson(): Promise<any> {
6060
const packageJsonPath = findup.sync("package.json");
6161

6262
assertHardhatInvariant(
63-
packageJsonPath !== null,
63+
packageJsonPath !== undefined,
6464
"Expected a package.json file in the current directory or in an ancestor directory"
6565
);
6666

packages/hardhat-core/test/internal/sentry/anonymizer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { Anonymizer } from "../../../src/internal/sentry/anonymizer";
66
const PROJECT_ROOT = "/path/to/project";
77

88
class MockedAnonymizer extends Anonymizer {
9-
public getFilePackageJsonPathResult: string | null = null;
9+
public getFilePackageJsonPathResult: string | undefined = undefined;
1010

11-
protected _getFilePackageJsonPath(_: string): string | null {
11+
protected _getFilePackageJsonPath(_: string): string | undefined {
1212
return this.getFilePackageJsonPathResult;
1313
}
1414
}

pnpm-lock.yaml

+2-55
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)