From 87a12703b229efa73334e61d7ed4448cb28167a9 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Tue, 30 Jul 2024 14:00:30 +0800 Subject: [PATCH] fix(`getJsdocProcessorPlugin`): ensure package.json file is consistently located --- src/getJsdocProcessorPlugin.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/getJsdocProcessorPlugin.js b/src/getJsdocProcessorPlugin.js index 34aee2dd..36eb544f 100644 --- a/src/getJsdocProcessorPlugin.js +++ b/src/getJsdocProcessorPlugin.js @@ -1,6 +1,8 @@ // Todo: Support TS by fenced block type -import {readFileSync} from 'fs'; +import {readFileSync} from 'node:fs'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; import * as espree from 'espree'; import { getRegexFromString, @@ -13,9 +15,11 @@ import { parseComment, } from '@es-joy/jsdoccomment'; +const __dirname = dirname(fileURLToPath(import.meta.url)); + const {version} = JSON.parse( // @ts-expect-error `Buffer` is ok for `JSON.parse` - readFileSync('./package.json') + readFileSync(join(__dirname, '../package.json')) ); // const zeroBasedLineIndexAdjust = -1;