From ed54a8746c58869be4acd5cdf7f40f7c43bac3a5 Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Sun, 1 Sep 2024 23:22:51 +0000 Subject: [PATCH] Promote import.meta.dirname --- README.md | 3 +-- base-server/index.d.ts | 5 ++--- create-reporter/index.js | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4192e3e..0514f8f 100644 --- a/README.md +++ b/README.md @@ -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' @@ -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 }) ) diff --git a/base-server/index.d.ts b/base-server/index.d.ts index bc1644f..9301909 100644 --- a/base-server/index.d.ts +++ b/base-server/index.d.ts @@ -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 @@ -197,7 +196,7 @@ export interface BaseServerOptions { * Default is `process.cwd()`. * * ```js - * root: __dirname + * root: import.meta.dirname * ``` */ root?: string diff --git a/create-reporter/index.js b/create-reporter/index.js index 73f0dac..39f8c0a 100644 --- a/create-reporter/index.js +++ b/create-reporter/index.js @@ -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' )