From 618fbb965e86bc137d0562365516173c197b7d8a Mon Sep 17 00:00:00 2001 From: GENTILHOMME Thomas Date: Sun, 29 Mar 2026 22:13:01 +0200 Subject: [PATCH] refactor: remove getDirNameFromUrl utils in favor of import.meta.dirname --- .changeset/great-sloths-tickle.md | 5 +++++ workspaces/scanner/src/registry/NpmRegistryProvider.ts | 4 +--- workspaces/scanner/src/utils/dirname.ts | 9 --------- workspaces/scanner/src/utils/index.ts | 1 - workspaces/scanner/src/utils/warnings.ts | 3 +-- 5 files changed, 7 insertions(+), 15 deletions(-) create mode 100644 .changeset/great-sloths-tickle.md delete mode 100644 workspaces/scanner/src/utils/dirname.ts diff --git a/.changeset/great-sloths-tickle.md b/.changeset/great-sloths-tickle.md new file mode 100644 index 00000000..3f5cd0f2 --- /dev/null +++ b/.changeset/great-sloths-tickle.md @@ -0,0 +1,5 @@ +--- +"@nodesecure/scanner": minor +--- + +Remove getDirNameFromUrl utilities in favor of import.meta.dirname diff --git a/workspaces/scanner/src/registry/NpmRegistryProvider.ts b/workspaces/scanner/src/registry/NpmRegistryProvider.ts index 89a550b5..48848283 100644 --- a/workspaces/scanner/src/registry/NpmRegistryProvider.ts +++ b/workspaces/scanner/src/registry/NpmRegistryProvider.ts @@ -21,13 +21,11 @@ import type { } from "../types.ts"; import { Logger } from "../class/logger.class.ts"; import { getLinks } from "../utils/getLinks.ts"; -import { getDirNameFromUrl } from "../utils/dirname.ts"; - // CONSTANTS const kNotFoundStatusCode = 404; await i18n.extendFromSystemPath( - path.join(getDirNameFromUrl(import.meta.url), "..", "i18n") + path.join(import.meta.dirname, "..", "i18n") ); type PackumentNpmApiOptions = { diff --git a/workspaces/scanner/src/utils/dirname.ts b/workspaces/scanner/src/utils/dirname.ts deleted file mode 100644 index 63b79059..00000000 --- a/workspaces/scanner/src/utils/dirname.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Import Node.js Dependencies -import { fileURLToPath } from "node:url"; -import { dirname } from "node:path"; - -export function getDirNameFromUrl(url: string | URL): string { - const filename = fileURLToPath(url); - - return dirname(filename); -} diff --git a/workspaces/scanner/src/utils/index.ts b/workspaces/scanner/src/utils/index.ts index 98623ece..053cec90 100644 --- a/workspaces/scanner/src/utils/index.ts +++ b/workspaces/scanner/src/utils/index.ts @@ -1,4 +1,3 @@ -export * from "./dirname.ts"; export * from "./warnings.ts"; export * from "./addMissingVersionFlags.ts"; export * from "./getLinks.ts"; diff --git a/workspaces/scanner/src/utils/warnings.ts b/workspaces/scanner/src/utils/warnings.ts index f0b1e74c..ebadd3cf 100644 --- a/workspaces/scanner/src/utils/warnings.ts +++ b/workspaces/scanner/src/utils/warnings.ts @@ -12,12 +12,11 @@ import { import type { Contact } from "@nodesecure/npm-types"; // Import Internal Dependencies -import { getDirNameFromUrl } from "./dirname.ts"; import { TopPackages } from "../class/TopPackages.class.ts"; import type { Dependency, GlobalWarning } from "../types.ts"; await i18n.extendFromSystemPath( - path.join(getDirNameFromUrl(import.meta.url), "..", "i18n") + path.join(import.meta.dirname, "..", "i18n") ); // CONSTANTS