An open API service indexing awesome lists of open source software.

https://github.com/your-local-developer/dirname_deno

Implementation of Node's __dirname and __filename for Deno
https://github.com/your-local-developer/dirname_deno

deno typescript

Last synced: about 2 months ago
JSON representation

Implementation of Node's __dirname and __filename for Deno

Awesome Lists containing this project

README

          


dirname_deno


nest.land
deno doc

An implementation of Node's __dirname and __filename for Deno


## Usage

### Get the current dirname and filename:

#### Method 1

```ts
/* main.ts */

import { fromMeta } from "https://x.nest.land/dirname_deno@0.3.0/mod.ts";
// or from "https://deno.land/x/dirname_deno@v0.3.0/mod.ts"

const { __dirname, __filename } = fromMeta(import.meta);

console.log(__dirname); // /home/you/projects/project/src
console.log(__filename); // /home/you/projects/project/src/main.ts
```

#### Method 2

```ts
/* main.ts */

import {
getDirname,
getFilename,
} from "https://x.nest.land/dirname_deno@0.3.0/mod.ts";
// or from "https://deno.land/x/dirname_deno@v0.3.0/mod.ts"

const dirname = getDirname(import.meta);
console.log(dirname); // /home/you/projects/project/src

const filename = getFilename(import.meta);
console.log(filename); // /home/you/projects/project/src/main.ts
```