提交 1ab97962 authored 作者: Camille Oudot's avatar Camille Oudot 提交者: Iñaki Baz Castillo

Node: extract version from package.json using require()

This allows JS bundlers such as webpack to embed the version string in the
bundle. Otherwise a bundled JS app would look for mediasoup's package.json
in "../.." on the filesystem (and it's very likely not there).
上级 ea0fb971
import * as fs from 'node:fs';
import * as path from 'node:path';
import { Logger } from './Logger'; import { Logger } from './Logger';
import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { EnhancedEventEmitter } from './EnhancedEventEmitter';
import { workerBin, Worker, WorkerSettings } from './Worker'; import { workerBin, Worker, WorkerSettings } from './Worker';
...@@ -16,9 +14,8 @@ export { types }; ...@@ -16,9 +14,8 @@ export { types };
/** /**
* Expose mediasoup version. * Expose mediasoup version.
*/ */
export const { version } = JSON.parse(fs.readFileSync( // eslint-disable-next-line @typescript-eslint/no-var-requires
path.join(__dirname, '..', '..', 'package.json'), { encoding: 'utf-8' } export const version: string = require('../../package.json').version;
));
/** /**
* Expose parseScalabilityMode() function. * Expose parseScalabilityMode() function.
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论