Skip to content
0

katanakit-js / useGetDirname

Function: useGetDirname() ​

ts
function useGetDirname(importMetaUrl): Promise<string>;

Defined in: src/infrastructure/filesystem/path.service.ts:63

Resolves the directory of a module from its import.meta.url.

Unlike import.meta.dirname, this works for any module you pass in, so a consumer's app resolves its own paths — never KatanaKit's dist/.

Parameters ​

ParameterTypeDescription
importMetaUrlstringYour module's import.meta.url.

Returns ​

Promise<string>

The absolute directory that contains the module.

Example ​

ts
import { useGetDirname } from "katanakit-js";

const dir = await useGetDirname(import.meta.url);
// "<project>/src/features/books"

Released under the MIT License.