Skip to content

Commit

Permalink
fix: bump find-up dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kiriyaga committed Oct 2, 2024
1 parent cd5581c commit c592846
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 106 deletions.
2 changes: 1 addition & 1 deletion packages/hardhat-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"env-paths": "^2.2.0",
"ethereum-cryptography": "^1.0.3",
"ethereumjs-abi": "^0.6.8",
"find-up": "^2.1.0",
"find-up": "^5.0.0",
"fp-ts": "1.19.3",
"fs-extra": "^7.0.1",
"glob": "7.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-core/src/internal/cli/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function getTaskFromTaskDefinition(taskDef: TaskDefinition): Task {
function getProjectId(): string | undefined {
const packageJsonPath = findup.sync("package.json");

if (packageJsonPath === null) {
if (!packageJsonPath) {
return undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function analyzeModuleNotFoundError(error: any, configPath: string) {

const packageJsonPath = findClosestPackageJson(throwingFile);

if (packageJsonPath === null) {
if (!packageJsonPath) {
return;
}

Expand Down
16 changes: 8 additions & 8 deletions packages/hardhat-core/src/internal/core/project-structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ const CTS_CONFIG_FILENAME = "hardhat.config.cts";

export function isCwdInsideProject() {
return (
findUp.sync(TS_CONFIG_FILENAME) !== null ||
findUp.sync(CTS_CONFIG_FILENAME) !== null ||
findUp.sync(CJS_CONFIG_FILENAME) !== null ||
findUp.sync(JS_CONFIG_FILENAME) !== null
findUp.sync(TS_CONFIG_FILENAME) !== undefined ||
findUp.sync(CTS_CONFIG_FILENAME) !== undefined ||
findUp.sync(CJS_CONFIG_FILENAME) !== undefined ||
findUp.sync(JS_CONFIG_FILENAME) !== undefined
);
}

export function getUserConfigPath() {
const tsConfigPath = findUp.sync(TS_CONFIG_FILENAME);
if (tsConfigPath !== null) {
if (tsConfigPath) {
return tsConfigPath;
}

const ctsConfigPath = findUp.sync(CTS_CONFIG_FILENAME);
if (ctsConfigPath !== null) {
if (ctsConfigPath) {
return ctsConfigPath;
}

const cjsConfigPath = findUp.sync(CJS_CONFIG_FILENAME);
if (cjsConfigPath !== null) {
if (cjsConfigPath) {
return cjsConfigPath;
}

const pathToConfigFile = findUp.sync(JS_CONFIG_FILENAME);
if (pathToConfigFile === null) {
if (!pathToConfigFile) {
throw new HardhatError(ERRORS.GENERAL.NOT_INSIDE_PROJECT);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-core/src/internal/sentry/anonymizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Anonymizer {
if (filename === this._configPath) {
const packageJsonPath = this._getFilePackageJsonPath(filename);

if (packageJsonPath === null) {
if (!packageJsonPath) {
// if we can't find a package.json, we just return the basename
return {
anonymizedFilename: path.basename(filename),
Expand Down Expand Up @@ -163,7 +163,7 @@ export class Anonymizer {
return false;
}

protected _getFilePackageJsonPath(filename: string): string | null {
protected _getFilePackageJsonPath(filename: string): string | undefined {
return findup.sync("package.json", {
cwd: path.dirname(filename),
});
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-core/src/internal/util/caller-package.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import findup from "find-up";
import path from "path";

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

Expand Down Expand Up @@ -35,7 +35,7 @@ export function getClosestCallerPackage(): string | undefined {
continue;
}

if (callerPackage === null) {
if (!callerPackage) {
return undefined;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat-core/src/internal/util/packageInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export interface PackageJson {
};
}

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

export async function getPackageName(file: string): Promise<string> {
const packageJsonPath = findClosestPackageJson(file);
if (packageJsonPath !== null && packageJsonPath !== "") {
if (packageJsonPath && packageJsonPath !== "") {
const packageJson: PackageJson = await fsExtra.readJSON(packageJsonPath);
return packageJson.name;
}
Expand All @@ -45,7 +45,7 @@ export function getHardhatVersion(): string {
const packageJsonPath = findClosestPackageJson(__filename);

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

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

assertHardhatInvariant(
packageJsonPath !== null,
packageJsonPath !== undefined,
"Expected a package.json file in the current directory or in an ancestor directory"
);

Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat-core/test/internal/sentry/anonymizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Anonymizer } from "../../../src/internal/sentry/anonymizer";
const PROJECT_ROOT = "/path/to/project";

class MockedAnonymizer extends Anonymizer {
public getFilePackageJsonPathResult: string | null = null;
public getFilePackageJsonPathResult: string | undefined = undefined;

protected _getFilePackageJsonPath(_: string): string | null {
protected _getFilePackageJsonPath(_: string): string | undefined {
return this.getFilePackageJsonPathResult;
}
}
Expand Down
Loading

0 comments on commit c592846

Please sign in to comment.