Skip to content

Commit 301eed6

Browse files
authored
fix: loading package.json (#587)
1 parent 2f24bf7 commit 301eed6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
"use strict";
99

1010
const requireIndex = require("requireindex");
11+
const path = require("node:path");
1112

12-
const pkg = __dirname.includes("/dist/")
13-
? // @ts-expect-error -- TODO: ESM/TypeScript conversion should fix this.
14-
require("../package.json") // eslint-disable-line n/no-missing-require -- this is the path when this file is compiled to dist/
15-
: // @ts-expect-error -- TODO: ESM/TypeScript conversion should fix this.
16-
require("./package.json");
13+
const pathParts = __dirname.split(path.sep);
14+
const pkg =
15+
pathParts[pathParts.length - 1] === "dist"
16+
? // @ts-expect-error -- TODO: ESM/TypeScript conversion should fix this.
17+
require("../package.json") // eslint-disable-line n/no-missing-require -- this is the path when this file is compiled to dist/
18+
: // @ts-expect-error -- TODO: ESM/TypeScript conversion should fix this.
19+
require("./package.json");
1720

1821
module.exports = {
1922
meta: {

0 commit comments

Comments
 (0)