Skip to content

Commit 18d530c

Browse files
Fix package.json not being read by getPackageVersion() function
1 parent 04d9090 commit 18d530c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: src/sdk/Utils/Utils.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ export class Utils {
1616

1717
public static getPackageVersion(): string {
1818
if (!this.PackageJSON) {
19-
const packageJsonPaths = ['../../../package.json', '../../../../package.json'];
20-
for (const packageJsonPath in packageJsonPaths) {
19+
const path = require('path');
20+
const possiblePackageJsonPaths = [
21+
path.join(__dirname, '../../../../package.json'),
22+
path.join(__dirname, '../../../package.json')
23+
];
24+
for (const packageJsonPath of possiblePackageJsonPaths) {
2125
try {
2226
this.PackageJSON = require(packageJsonPath);
2327
} catch (e) {}
24-
if (!this.PackageJSON) break;
28+
if (this.PackageJSON) break;
2529
}
2630
}
2731
return this.PackageJSON.version

0 commit comments

Comments
 (0)