Skip to content

Commit

Permalink
Promote import.meta.dirname
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Sep 1, 2024
1 parent 7f388cc commit ed54a87
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ This repository contains Logux server with:
### Logux Server as Framework

```js
import { fileURLToPath } from 'url'
import { isFirstOlder } from '@logux/core'
import { dirname } from 'path'
import { Server } from '@logux/server'
Expand All @@ -39,7 +38,7 @@ const server = new Server(
Server.loadOptions(process, {
subprotocol: '1.0.0',
supports: '1.x',
fileUrl: import.meta.url
root: import.meta.dirname
})
)

Expand Down
5 changes: 2 additions & 3 deletions base-server/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ export interface BaseServerOptions {
env?: 'development' | 'production'

/**
* URL of main JS file in the root dir. Shortcut to set `root` in ES modules
* without `fileURLToPath`.
* URL of main JS file in the root dir.
*
* ```
* fileUrl: import.meta.url
Expand Down Expand Up @@ -197,7 +196,7 @@ export interface BaseServerOptions {
* Default is `process.cwd()`.
*
* ```js
* root: __dirname
* root: import.meta.dirname
* ```
*/
root?: string
Expand Down
6 changes: 3 additions & 3 deletions create-reporter/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os from 'node:os'
import { dirname, join, sep } from 'node:path'
import { join, sep } from 'node:path'
import { fileURLToPath } from 'node:url'
import pico from 'picocolors'
import pino from 'pino'

const __dirname = dirname(fileURLToPath(import.meta.url))
const root = join(fileURLToPath(import.meta.url), '..', '..')
export const PATH_TO_PRETTIFYING_PINO_TRANSPORT = join(
__dirname,
root,
'../human-formatter/index.js'
)

Expand Down

0 comments on commit ed54a87

Please sign in to comment.