Skip to content

Commit 87a1270

Browse files
committedJul 30, 2024·
fix(getJsdocProcessorPlugin): ensure package.json file is consistently located
1 parent 2fbd47c commit 87a1270

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

Diff for: ‎src/getJsdocProcessorPlugin.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Todo: Support TS by fenced block type
22

3-
import {readFileSync} from 'fs';
3+
import {readFileSync} from 'node:fs';
4+
import { dirname, join } from 'node:path';
5+
import { fileURLToPath } from 'node:url';
46
import * as espree from 'espree';
57
import {
68
getRegexFromString,
@@ -13,9 +15,11 @@ import {
1315
parseComment,
1416
} from '@es-joy/jsdoccomment';
1517

18+
const __dirname = dirname(fileURLToPath(import.meta.url));
19+
1620
const {version} = JSON.parse(
1721
// @ts-expect-error `Buffer` is ok for `JSON.parse`
18-
readFileSync('./package.json')
22+
readFileSync(join(__dirname, '../package.json'))
1923
);
2024

2125
// const zeroBasedLineIndexAdjust = -1;

0 commit comments

Comments
 (0)
Please sign in to comment.