Skip to content

Commit c58ca1f

Browse files
feat(NODE-7311): Replace process.platform with os.platform() (#4822)
1 parent f0af829 commit c58ca1f

File tree

12 files changed

+26
-17
lines changed

12 files changed

+26
-17
lines changed

src/cmap/auth/gssapi.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as dns from 'dns';
2+
import * as os from 'os';
23

34
import { getKerberos, type Kerberos, type KerberosClient } from '../../deps';
45
import { MongoInvalidArgumentError, MongoMissingCredentialsError } from '../../error';
@@ -97,7 +98,7 @@ async function makeKerberosClient(authContext: AuthContext): Promise<KerberosCli
9798
}
9899

99100
const spnHost = mechanismProperties.SERVICE_HOST ?? host;
100-
let spn = `${serviceName}${process.platform === 'win32' ? '/' : '@'}${spnHost}`;
101+
let spn = `${serviceName}${os.platform() === 'win32' ? '/' : '@'}${spnHost}`;
101102
if ('SERVICE_REALM' in mechanismProperties) {
102103
spn = `${spn}@${mechanismProperties.SERVICE_REALM}`;
103104
}

src/cmap/handshake/client_metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export async function makeClientMetadata(
157157

158158
// Note: order matters, os.type is last so it will be removed last if we're at maxSize
159159
const osInfo = new Map()
160-
.set('name', process.platform)
160+
.set('name', os.platform())
161161
.set('architecture', os.arch())
162162
.set('version', os.release())
163163
.set('type', os.type());

test/benchmarks/driver_bench/src/main.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const systemInfo = () =>
7171
`\n- cpu: ${platform.name}`,
7272
`- cores: ${platform.cores}`,
7373
`- arch: ${os.arch()}`,
74-
`- os: ${process.platform} (${os.release()})`,
74+
`- os: ${os.platform()} (${os.release()})`,
7575
`- ram: ${platform.ram}`,
7676
`- node: ${process.version}`,
7777
`- running ${total} benchmarks`,

test/integration/node-specific/examples/change_streams.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
const { setTimeout } = require('timers');
55
const setupDatabase = require('../../shared').setupDatabase;
66
const expect = require('chai').expect;
7+
const os = require('os');
78

89
// TODO: NODE-3819: Unskip flaky MacOS/Windows tests.
9-
const maybeDescribe = process.platform !== 'linux' ? describe.skip : describe;
10+
const maybeDescribe = os.platform() !== 'linux' ? describe.skip : describe;
1011
maybeDescribe('examples(change-stream):', function () {
1112
let client;
1213
let db;

test/integration/node-specific/ipv6.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai';
22
import * as net from 'net';
3-
import * as process from 'process';
3+
import * as os from 'os';
44
import * as sinon from 'sinon';
55

66
import {
@@ -16,7 +16,7 @@ describe('IPv6 Addresses', () => {
1616

1717
beforeEach(async function () {
1818
if (
19-
process.platform === 'linux' ||
19+
os.platform() === 'linux' ||
2020
this.configuration.topologyType !== TopologyType.ReplicaSetWithPrimary
2121
) {
2222
if (this.currentTest) {

test/integration/uri-options/uri.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from 'chai';
2+
import * as os from 'os';
23
import * as sinon from 'sinon';
34

45
import { Topology } from '../../../src/sdam/topology';
@@ -45,7 +46,7 @@ describe('URI', function () {
4546
metadata: { requires: { topology: 'single' } },
4647

4748
test: async function () {
48-
if (process.platform === 'win32') {
49+
if (os.platform() === 'win32') {
4950
return;
5051
}
5152

test/manual/kerberos.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as chai from 'chai';
22
import { promises as dns } from 'dns';
3+
import * as os from 'os';
34
import * as sinon from 'sinon';
45

56
import { MongoClient } from '../../src';
@@ -50,7 +51,7 @@ describe('Kerberos', function () {
5051

5152
context('when passing in CANONICALIZE_HOST_NAME', function () {
5253
beforeEach(function () {
53-
if (process.platform === 'darwin') {
54+
if (os.platform() === 'darwin') {
5455
this.currentTest.skipReason =
5556
'DNS does not resolve with proper CNAME record on evergreen MacOS';
5657
this.skip();

test/manual/tls_support.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as tls from 'node:tls';
44
import { expect } from 'chai';
55
import { promises as fs } from 'fs';
66
import ConnectionString from 'mongodb-connection-string-url';
7+
import * as os from 'os';
78
import * as sinon from 'sinon';
89

910
import { MongoClient, type MongoClientOptions, MongoServerSelectionError } from '../../src';
@@ -36,7 +37,7 @@ describe('TLS Support', function () {
3637
beforeEach(function () {
3738
if (
3839
this.currentTest?.title === 'should connect with tls via url options' &&
39-
process.platform === 'win32'
40+
os.platform() === 'win32'
4041
) {
4142
this.currentTest.skipReason = 'TODO(NODE-5803): Un-skip Windows TLS tests via URL';
4243
return this.skip();

test/tools/runner/filters/client_encryption_filter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { readFile } from 'fs/promises';
2+
import * as os from 'os';
23
import { dirname, resolve } from 'path';
34
import * as process from 'process';
45
import { satisfies } from 'semver';
@@ -74,7 +75,7 @@ export class ClientSideEncryptionFilter extends Filter {
7475
}
7576

7677
// TODO(NODE-3401): unskip csfle tests on windows
77-
if (process.env.TEST_CSFLE && process.platform !== 'win32') {
78+
if (process.env.TEST_CSFLE && os.platform() !== 'win32') {
7879
if (this.version == null) {
7980
throw new Error('FLE tests must run, but mongodb client encryption was not installed.');
8081
}

test/tools/runner/filters/os_filter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as os from 'os';
2+
13
import { Filter } from './filter';
24

35
/**
@@ -17,7 +19,7 @@ export class OSFilter extends Filter {
1719
constructor() {
1820
super();
1921
// Get environmental variables that are known
20-
this.platform = process.platform;
22+
this.platform = os.platform();
2123
}
2224

2325
filter(test: { metadata?: MongoDBMetadataUI }) {

0 commit comments

Comments
 (0)