-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
f81046c
commit 09870d0
Showing
7 changed files
with
48 additions
and
61 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,40 +1,31 @@ | ||
declare const macosRelease: { | ||
/** | ||
Get the name and version of a macOS release from the Darwin version. | ||
/** | ||
Get the name and version of a macOS release from the Darwin version. | ||
@param release - By default, the current operating system is used, but you can supply a custom [Darwin kernel version](https://en.wikipedia.org/wiki/Darwin_%28operating_system%29#Release_history), which is the output of [`os.release()`](https://nodejs.org/api/os.html#os_os_release). | ||
@param release - By default, the current operating system is used, but you can supply a custom [Darwin kernel version](https://en.wikipedia.org/wiki/Darwin_%28operating_system%29#Release_history), which is the output of [`os.release()`](https://nodejs.org/api/os.html#os_os_release). | ||
@example | ||
``` | ||
import * as os from 'os'; | ||
import macosRelease = require('macos-release'); | ||
@example | ||
``` | ||
import os from 'node:os'; | ||
import macosRelease from 'macos-release'; | ||
// On a macOS Sierra system | ||
// On a macOS Sierra system | ||
macosRelease(); | ||
//=> {name: 'Sierra', version: '10.12'} | ||
macosRelease(); | ||
//=> {name: 'Sierra', version: '10.12'} | ||
os.release(); | ||
//=> 13.2.0 | ||
// This is the Darwin kernel version | ||
os.release(); | ||
//=> 13.2.0 | ||
// This is the Darwin kernel version | ||
macosRelease(os.release()); | ||
//=> {name: 'Sierra', version: '10.12'} | ||
macosRelease(os.release()); | ||
//=> {name: 'Sierra', version: '10.12'} | ||
macosRelease('14.0.0'); | ||
//=> {name: 'Yosemite', version: '10.10'} | ||
macosRelease('14.0.0'); | ||
//=> {name: 'Yosemite', version: '10.10'} | ||
macosRelease('20.0.0'); | ||
//=> {name: 'Big Sur', version: '11'} | ||
``` | ||
*/ | ||
(): {name: string, version: string} | ||
(release: string): {name: string, version: string} | undefined; | ||
|
||
// TODO: remove this in the next major version, refactor the whole definition to: | ||
// declare function macosRelease(release?: string): {name: string, version: string}; | ||
// export = macosRelease; | ||
default: typeof macosRelease; | ||
}; | ||
|
||
export = macosRelease; | ||
macosRelease('20.0.0'); | ||
//=> {name: 'Big Sur', version: '11'} | ||
``` | ||
*/ | ||
export default function macosRelease(): {name: string; version: string}; | ||
export default function macosRelease(release: string): {name: string; version: string} | undefined; |
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,5 +1,5 @@ | ||
import {expectType} from 'tsd'; | ||
import macosRelease = require('.'); | ||
import macosRelease from './index.js'; | ||
|
||
expectType<{name: string, version: string}>(macosRelease()); | ||
expectType<{name: string, version: string} | undefined>(macosRelease('foo')); | ||
expectType<{name: string; version: string}>(macosRelease()); | ||
expectType<{name: string; version: string} | undefined>(macosRelease('foo')); |
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
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,14 +1,14 @@ | ||
import test from 'ava'; | ||
import macosRelease from '.'; | ||
import macosRelease from './index.js'; | ||
|
||
test('main', t => { | ||
t.deepEqual(macosRelease('13.2.0'), { | ||
name: 'Mavericks', | ||
version: '10.9' | ||
version: '10.9', | ||
}); | ||
|
||
t.deepEqual(macosRelease('20.0.0'), { | ||
name: 'Big Sur', | ||
version: '11' | ||
version: '11', | ||
}); | ||
}); |