Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 6 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions packages/native-machine-id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"author": "Compass Team <[email protected]>",
"gypfile": true,
"dependencies": {
"bindings": "^1.5.0",
"node-addon-api": "^8.0.0"
},
"license": "Apache-2.0",
Expand Down Expand Up @@ -53,15 +52,15 @@
"@mongodb-js/tsconfig-devtools": "^1.0.3",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.1.1",
"@types/sinon-chai": "^3.2.5",
"@types/node": "^17.0.35",
"@types/sinon-chai": "^3.2.5",
"chai": "^4.5.0",
"eslint": "^7.25.0",
"gen-esm-wrapper": "^1.1.1",
"mocha": "^8.4.0",
"chai": "^4.5.0",
"node-machine-id": "^1.1.12",
"typescript": "^5.0.4",
"ts-node": "^10.9.2"
"ts-node": "^10.9.2",
"typescript": "^5.0.4"
},
"keywords": [
"machine id",
Expand Down
18 changes: 16 additions & 2 deletions packages/native-machine-id/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import bindings from 'bindings';
import { createHash } from 'crypto';
import { promisify } from 'util';

const binding = bindings('native_machine_id');
type NativeMachineIdModule = {
getMachineIdSync: () => string;
getMachineIdAsync: (cb: (err: unknown, id: string) => void) => void;
}

const binding = (() => {
try {
return require('../build/Release/native_machine_id.node') as NativeMachineIdModule;
} catch (outerError) {
try {
return require('../build/Debug/native_machine_id.node') as NativeMachineIdModule;
} catch {
throw outerError;
}
}
})();

function getMachineIdFromBindingSync(): string | undefined {
try {
Expand Down
Loading