From 26c25baf289a49bb5c1f92027212a8286785906e Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Thu, 28 May 2026 11:55:21 -0400 Subject: [PATCH] feat: Remove usage of graceful-fs library --- js/package.json | 2 -- js/src/cli/jest/nodeModulesPaths.ts | 6 ++---- js/src/cli/jest/tryRealpath.ts | 20 -------------------- pnpm-lock.yaml | 13 ------------- 4 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 js/src/cli/jest/tryRealpath.ts diff --git a/js/package.json b/js/package.json index ebb827a75..f0d6ca8e8 100644 --- a/js/package.json +++ b/js/package.json @@ -169,7 +169,6 @@ "@types/cli-progress": "^3.11.5", "@types/cors": "^2.8.17", "@types/express": "^5.0.0", - "@types/graceful-fs": "^4.1.9", "@types/http-errors": "^2.0.4", "@types/mustache": "^4.2.5", "@types/node": "^20.10.5", @@ -210,7 +209,6 @@ "esbuild": "0.28.0", "eventsource-parser": "^1.1.2", "express": "^5.2.1", - "graceful-fs": "^4.2.11", "http-errors": "^2.0.0", "minimatch": "^10.2.5", "module-details-from-path": "^1.0.4", diff --git a/js/src/cli/jest/nodeModulesPaths.ts b/js/src/cli/jest/nodeModulesPaths.ts index a388888ce..f04748e9a 100644 --- a/js/src/cli/jest/nodeModulesPaths.ts +++ b/js/src/cli/jest/nodeModulesPaths.ts @@ -8,9 +8,7 @@ */ import * as path from "node:path"; - -// BRAINTRUST: This was changed to be a relative import -import tryRealpath from "./tryRealpath"; +import { realpathSync } from "node:fs"; type NodeModulesPathsOptions = { moduleDirectory?: Array; @@ -41,7 +39,7 @@ export default function nodeModulesPaths( // traverses parents of the physical path, not the symlinked path let physicalBasedir; try { - physicalBasedir = tryRealpath(basedirAbs); + physicalBasedir = realpathSync.native(basedirAbs); } catch { // realpath can throw, e.g. on mapped drives physicalBasedir = basedirAbs; diff --git a/js/src/cli/jest/tryRealpath.ts b/js/src/cli/jest/tryRealpath.ts deleted file mode 100644 index ebce7548a..000000000 --- a/js/src/cli/jest/tryRealpath.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import { realpathSync } from "graceful-fs"; - -export default function tryRealpath(path: string): string { - try { - path = realpathSync.native(path); - } catch (error: any) { - if (error.code !== "ENOENT" && error.code !== "EISDIR") { - throw error; - } - } - - return path; -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0dc5bbcf9..52dd0f6dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -368,9 +368,6 @@ importers: express: specifier: ^5.2.1 version: 5.2.1 - graceful-fs: - specifier: ^4.2.11 - version: 4.2.11 http-errors: specifier: ^2.0.0 version: 2.0.1 @@ -426,9 +423,6 @@ importers: '@types/express': specifier: ^5.0.0 version: 5.0.1 - '@types/graceful-fs': - specifier: ^4.1.9 - version: 4.1.9 '@types/http-errors': specifier: ^2.0.4 version: 2.0.4 @@ -1709,9 +1703,6 @@ packages: '@types/express@5.0.1': resolution: {integrity: sha512-UZUw8vjpWFXuDnjFTh7/5c2TWDlQqeXHi6hcN7F2XSVT5P+WmUnnbFS3KA6Jnc6IsEqI2qCVu2bK0R0J4A8ZQQ==} - '@types/graceful-fs@4.1.9': - resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} - '@types/hast@3.0.4': resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} @@ -5389,10 +5380,6 @@ snapshots: '@types/express-serve-static-core': 5.0.6 '@types/serve-static': 1.15.7 - '@types/graceful-fs@4.1.9': - dependencies: - '@types/node': 22.19.1 - '@types/hast@3.0.4': dependencies: '@types/unist': 3.0.3