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
- Host: GitHub
- URL: https://github.com/your-local-developer/dirname_deno
- Owner: your-local-developer
- License: mit
- Created: 2021-12-29T20:41:10.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-03T21:44:02.000Z (over 4 years ago)
- Last Synced: 2024-10-26T06:51:52.036Z (over 1 year ago)
- Topics: deno, typescript
- Language: TypeScript
- Homepage: https://deno.land/x/dirname_deno
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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
```