Socket
Socket
Sign inDemoInstall

macos-version

Package Overview
Dependencies
3
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

macos-version

Get or check the current macOS version


Version published
Maintainers
1
Weekly downloads
5,856
decreased by-2.37%

Weekly downloads

Readme

Source

macos-version

Get or check the current macOS version

Install

$ npm install macos-version

Usage

import {
	macOSVersion,
	isMacOSVersion,
	isMacOSVersionGreaterThanOrEqualTo,
	assertMacOSVersion,
	assertMacOSVersionGreaterThanOrEqualTo,
	assertMacOS,
	isMacOS,
} from 'macos-version';

macOSVersion();
//=> '10.12.3'

isMacOSVersion('>10.10');
//=> true

isMacOSVersionGreaterThanOrEqualTo('10.10');
//=> true

assertMacOSVersion('>=10.12.5');
//=> [Error: Requires macOS >=10.12.5]

assertMacOSVersionGreaterThanOrEqualTo('10.12.5');
//=> [Error: Requires macOS 10.12.5 or later]

assertMacOS();
//=> [Error: Requires macOS]

if (isMacOS) {
	console.log('macOS');
}

API

macOSVersion()

Returns the macOS version or undefined if the platform is not macOS.

isMacOSVersion(semverRange)

Returns a boolean of whether the specified semver range matches the macOS version.

isMacOSVersionGreaterThanOrEqualTo(version)

Returns a boolean of whether the macOS version is greater than or equal to the specified version.

assertMacOSVersion(semverRange)

Throws an error if the specified semver range does not match the macOS version.

assertMacOSVersionGreaterThanOrEqualTo(version)

Throws an error if the macOS version is not greater than or equal to the specified version.

Prefer this over .assert() whenever possible as it outputs a more user-friendly error message.

assertMacOS()

Throws an error if the platform is not macOS.

isMacOS

Type: boolean

Whether the platform is macOS.

  • macos-version-cli - CLI for this module
  • macos-release - Get the name and version of a macOS release from the Darwin version

Keywords

FAQs

Last updated on 12 Aug 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc