Use fs package to read package.json to avoid creating nested dist folder
This commit is contained in:
Родитель
2e35ec15ed
Коммит
fb25863bf2
|
@ -8,7 +8,6 @@
|
|||
"target": "es5",
|
||||
"esModuleInterop": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"resolveJsonModule": true,
|
||||
"strict": true,
|
||||
"noErrorTruncation": true,
|
||||
"module": "ES6",
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
"@typescript-eslint/parser": "^3.0.2",
|
||||
"eslint": "^7.4.0",
|
||||
"eslint-plugin-react": "^7.20.0",
|
||||
"fs": "^0.0.2",
|
||||
"jasmine-core": "^3.5.0",
|
||||
"karma": "^6.3.17",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
|
|
16
src/utils.ts
16
src/utils.ts
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { EmbedProps } from "./PowerBIEmbed";
|
||||
import packageInfo from '../package.json';
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
/**
|
||||
* Get JSON string representation of the given map.
|
||||
|
@ -44,5 +44,15 @@ export function stringifyMap(map: EmbedProps['eventHandlers']): string {
|
|||
};
|
||||
|
||||
// SDK information to be used with service instance
|
||||
export const SdkType: string = "powerbi-client-react";
|
||||
export const SdkWrapperVersion: string = packageInfo.version;
|
||||
export const SdkType = "powerbi-client-react";
|
||||
export const SdkWrapperVersion: string = getSdkWrapperVersion();
|
||||
|
||||
function getSdkWrapperVersion() {
|
||||
try {
|
||||
const packageInfo = JSON.parse(readFileSync('../package.json').toString());
|
||||
return packageInfo.version;
|
||||
}
|
||||
catch {
|
||||
return "";
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче