MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / getDarwinInfo

Function getDarwinInfo

packages/node-core/src/integrations/context.ts:431–464  ·  view source on GitHub ↗

Loads the macOS operating system context.

()

Source from the content-addressed store, hash-verified

429
430/** Loads the macOS operating system context. */
431async function getDarwinInfo(): Promise<OsContext> {
432 // Default values that will be used in case no operating system information
433 // can be loaded. The default version is computed via heuristics from the
434 // kernel version, but the build ID is missing.
435 const darwinInfo: OsContext = {
436 kernel_version: os.release(),
437 name: 'Mac OS X',
438 version: `10.${Number(os.release().split('.')[0]) - 4}`,
439 };
440
441 try {
442 // We try to load the actual macOS version by executing the `sw_vers` tool.
443 // This tool should be available on every standard macOS installation. In
444 // case this fails, we stick with the values computed above.
445
446 const output = await new Promise<string>((resolve, reject) => {
447 execFile('/usr/bin/sw_vers', (error: Error | null, stdout: string) => {
448 if (error) {
449 reject(error);
450 return;
451 }
452 resolve(stdout);
453 });
454 });
455
456 darwinInfo.name = matchFirst(/^ProductName:\s+(.*)$/m, output);
457 darwinInfo.version = matchFirst(/^ProductVersion:\s+(.*)$/m, output);
458 darwinInfo.build = matchFirst(/^BuildVersion:\s+(.*)$/m, output);
459 } catch {
460 // ignore
461 }
462
463 return darwinInfo;
464}
465
466/** Returns a distribution identifier to look up version callbacks. */
467function getLinuxDistroId(name: string): string {

Callers 1

getOsContextFunction · 0.85

Calls 3

matchFirstFunction · 0.85
releaseMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected