-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
a4d2601
commit b42707c
Showing
7 changed files
with
210 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,93 @@ | ||
declare const macosVersion: { | ||
/** | ||
@returns The macOS version or `undefined` if the platform is not macOS. | ||
@example | ||
``` | ||
import macosVersion = require('macos-version'); | ||
macosVersion(); | ||
//=> '10.12.3' | ||
``` | ||
*/ | ||
(): string | undefined; | ||
|
||
/** | ||
@returns Whether the specified [semver range](https://github.com/npm/node-semver#ranges) matches the macOS version. | ||
@example | ||
``` | ||
import macosVersion = require('macos-version'); | ||
macosVersion.is('>10.10'); | ||
//=> true | ||
``` | ||
*/ | ||
is(semverRange: string): boolean; | ||
|
||
/** | ||
@returns Whether the macOS version is greater than or equal to the specified version. | ||
@example | ||
``` | ||
import macosVersion = require('macos-version'); | ||
macosVersion.isGreaterThanOrEqualTo('10.10'); | ||
//=> true | ||
``` | ||
*/ | ||
isGreaterThanOrEqualTo(version: string): boolean; | ||
|
||
/** | ||
Throws an error if the specified [semver range](https://github.com/npm/node-semver#ranges) does not match the macOS version. | ||
@example | ||
``` | ||
import macosVersion = require('macos-version'); | ||
macosVersion.assert('>=10.12.5'); | ||
//=> [Error: Requires macOS >=10.12.5] | ||
``` | ||
*/ | ||
assert(semverRange: string): void; | ||
|
||
/** | ||
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._ | ||
@example | ||
``` | ||
import macosVersion = require('macos-version'); | ||
macosVersion.assertGreaterThanOrEqualTo('10.12.5'); | ||
//=> [Error: Requires macOS 10.12.5 or later] | ||
``` | ||
*/ | ||
assertGreaterThanOrEqualTo(version: string): void; | ||
|
||
/** | ||
Throws an error if platform is not macOS. | ||
@example | ||
``` | ||
import macosVersion = require('macos-version'); | ||
macosVersion.assertMacOS(); | ||
//=> [Error: Requires macOS] | ||
``` | ||
*/ | ||
assertMacOS(): void; | ||
|
||
/** | ||
Whether the platform is macOS. | ||
@example | ||
``` | ||
import macosVersion = require('macos-version'); | ||
if (macosVersion.isMacOS) { | ||
console.log('macOS'); | ||
} | ||
``` | ||
*/ | ||
readonly isMacOS: boolean; | ||
|
||
// TODO: remove this in the next major version | ||
default: typeof macosVersion; | ||
}; | ||
|
||
export = macosVersion; | ||
/** | ||
@returns The macOS version or `undefined` if the platform is not macOS. | ||
@example | ||
``` | ||
import {macOSVersion} from 'macos-version'; | ||
macOSVersion(); | ||
//=> '10.12.3' | ||
``` | ||
*/ | ||
export function macOSVersion(): string | undefined; | ||
|
||
/** | ||
@returns Whether the specified [semver range](https://github.com/npm/node-semver#ranges) matches the macOS version. | ||
@example | ||
``` | ||
import {isMacOSVersion} from 'macos-version'; | ||
isMacOSVersion('>10.10'); | ||
//=> true | ||
``` | ||
*/ | ||
export function isMacOSVersion(semverRange: string): boolean; | ||
|
||
/** | ||
@returns Whether the macOS version is greater than or equal to the specified version. | ||
@example | ||
``` | ||
import {isMacOSVersionGreaterThanOrEqualTo} from 'macos-version'; | ||
isMacOSVersionGreaterThanOrEqualTo('10.10'); | ||
//=> true | ||
``` | ||
*/ | ||
export function isMacOSVersionGreaterThanOrEqualTo(version: string): boolean; | ||
|
||
/** | ||
Throws an error if the specified [semver range](https://github.com/npm/node-semver#ranges) does not match the macOS version. | ||
@example | ||
``` | ||
import {assertMacOSVersion} from 'macos-version'; | ||
assertMacOSVersion('>=10.12.5'); | ||
//=> [Error: Requires macOS >=10.12.5] | ||
``` | ||
*/ | ||
export function assertMacOSVersion(semverRange: string): void; | ||
|
||
/** | ||
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._ | ||
@example | ||
``` | ||
import {assertMacOSVersionGreaterThanOrEqualTo} from 'macos-version'; | ||
assertMacOSVersionGreaterThanOrEqualTo('10.12.5'); | ||
//=> [Error: Requires macOS 10.12.5 or later] | ||
``` | ||
*/ | ||
export function assertMacOSVersionGreaterThanOrEqualTo(version: string): void; | ||
|
||
/** | ||
Throws an error if platform is not macOS. | ||
@example | ||
``` | ||
import {assertMacOS} from 'macos-version'; | ||
assertMacOS(); | ||
//=> [Error: Requires macOS] | ||
``` | ||
*/ | ||
export function assertMacOS(): void; | ||
|
||
/** | ||
Whether the platform is macOS. | ||
@example | ||
``` | ||
import {isMacOS} from 'macos-version'; | ||
if (isMacOS) { | ||
console.log('macOS'); | ||
} | ||
``` | ||
*/ | ||
export const isMacOS: boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
import {expectType} from 'tsd'; | ||
import macosVersion = require('.'); | ||
import { | ||
macOSVersion, | ||
isMacOSVersion, | ||
isMacOSVersionGreaterThanOrEqualTo, | ||
assertMacOSVersion, | ||
assertMacOSVersionGreaterThanOrEqualTo, | ||
assertMacOS, | ||
isMacOS, | ||
} from './index.js'; | ||
|
||
expectType<string | undefined>(macosVersion()); | ||
expectType<boolean>(macosVersion.is('>10.10')); | ||
expectType<boolean>(macosVersion.isGreaterThanOrEqualTo('10.12.5')); | ||
expectType<void>(macosVersion.assert('>10.10')); | ||
expectType<void>(macosVersion.assertGreaterThanOrEqualTo('10.10')); | ||
expectType<void>(macosVersion.assertMacOS()); | ||
expectType<boolean>(macosVersion.isMacOS); | ||
expectType<string | undefined>(macOSVersion()); | ||
expectType<boolean>(isMacOSVersion('>10.10')); | ||
expectType<boolean>(isMacOSVersionGreaterThanOrEqualTo('10.12.5')); | ||
expectType<void>(assertMacOSVersion('>10.10')); | ||
expectType<void>(assertMacOSVersionGreaterThanOrEqualTo('10.10')); | ||
expectType<void>(assertMacOS()); | ||
expectType<boolean>(isMacOS); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ | |
"email": "[email protected]", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=6" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
|
@@ -35,11 +37,11 @@ | |
"condition" | ||
], | ||
"dependencies": { | ||
"semver": "^5.6.0" | ||
"semver": "^7.3.5" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.1", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
Oops, something went wrong.