Skip to main content
Module

x/dirname/mod.ts

The Deno implementation of __dirname of Node
Latest
File
import { IMakeLoc, IMeta } from './types.ts'import { join } from 'https://x.nest.land/std@0.73.0/path/mod.ts'
// make a __dirname objectexport default function (meta: IMeta): IMakeLoc { const iURL = meta.url, fileStartRegex = /(^(file:)((\/\/)?))/, __dirname = join(iURL, '../') .replace(fileStartRegex, '') .replace(/(\/$)/, ''), __filename = iURL.replace(fileStartRegex, '')
return { __dirname, __filename }}