Skip to content

Commit

Permalink
fix(path,exception): make athenna compatible with bun
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Sep 22, 2023
1 parent 16331b4 commit 3a0b2ab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/common",
"version": "4.13.1",
"version": "4.13.2",
"description": "The Athenna common helpers to use in any Node.js ESM project.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/Exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import * as changeCase from 'change-case'
import Youch from 'youch'
import YouchTerminal from 'youch-terminal'

import { readFile } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { Color } from '#src/helpers/Color'
import { Options } from '#src/helpers/Options'
import type { ExceptionJson } from '#src/types'
Expand Down
8 changes: 7 additions & 1 deletion src/helpers/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,13 @@ export class Path {
*/
public static this(subPath = sep, stackIndex = 1): string {
const stack = callSite()
const requester = dirname(fileURLToPath(stack[stackIndex].getFileName()))
let fileName = stack[stackIndex].getFileName()

if (fileName.startsWith('file:')) {
fileName = fileURLToPath(fileName)
}

const requester = dirname(fileName)
const execDir = normalize(requester.concat(sep, normalize(subPath)))

return this.removeSlashes(execDir)
Expand Down

0 comments on commit 3a0b2ab

Please sign in to comment.