Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use require instead of readFileSync for driver.version (#2937) #2652

Merged
merged 3 commits into from
Dec 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import type { OperationOptions, OperationBase, Hint } from './operations/operati
import type { ClientSession } from './sessions';
import { ReadConcern } from './read_concern';
import type { Connection } from './cmap/connection';
import { readFileSync } from 'fs';
import { resolve } from 'path';
import { Document, resolveBSONOptions } from './bson';
import type { IndexSpecification, IndexDirection } from './operations/indexes';
import type { Explain } from './explain';
Expand Down Expand Up @@ -885,9 +883,8 @@ export interface ClientMetadataOptions {
appname?: string;
}

const NODE_DRIVER_VERSION = JSON.parse(
readFileSync(resolve(__dirname, '..', 'package.json'), { encoding: 'utf-8' })
).version;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const NODE_DRIVER_VERSION = require('../package.json').version;

export function makeClientMetadata(options: ClientMetadataOptions): ClientMetadata {
options = options || {};
Expand Down