pax_global_header00006660000000000000000000000064144376024720014523gustar00rootroot0000000000000052 comment=494c0dfd0848bd436ae2fb3ce53ee88dbdf2b367 macos-release-3.2.0/000077500000000000000000000000001443760247200142455ustar00rootroot00000000000000macos-release-3.2.0/.editorconfig000066400000000000000000000002571443760247200167260ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 macos-release-3.2.0/.gitattributes000066400000000000000000000000231443760247200171330ustar00rootroot00000000000000* text=auto eol=lf macos-release-3.2.0/.github/000077500000000000000000000000001443760247200156055ustar00rootroot00000000000000macos-release-3.2.0/.github/funding.yml000066400000000000000000000000611443760247200177570ustar00rootroot00000000000000github: sindresorhus tidelift: npm/macos-release macos-release-3.2.0/.github/security.md000066400000000000000000000002631443760247200177770ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. macos-release-3.2.0/.github/workflows/000077500000000000000000000000001443760247200176425ustar00rootroot00000000000000macos-release-3.2.0/.github/workflows/main.yml000066400000000000000000000006261443760247200213150ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 16 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test macos-release-3.2.0/.gitignore000066400000000000000000000000271443760247200162340ustar00rootroot00000000000000node_modules yarn.lock macos-release-3.2.0/.npmrc000066400000000000000000000000231443760247200153600ustar00rootroot00000000000000package-lock=false macos-release-3.2.0/index.d.ts000066400000000000000000000017111443760247200161460ustar00rootroot00000000000000/** 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). @example ``` import os from 'node:os'; import macosRelease from 'macos-release'; // On a macOS Sierra system macosRelease(); //=> {name: 'Sierra', version: '10.12'} os.release(); //=> 13.2.0 // This is the Darwin kernel version macosRelease(os.release()); //=> {name: 'Sierra', version: '10.12'} macosRelease('14.0.0'); //=> {name: 'Yosemite', version: '10.10'} 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; macos-release-3.2.0/index.js000066400000000000000000000014451443760247200157160ustar00rootroot00000000000000import os from 'node:os'; const nameMap = new Map([ [23, ['Sonoma', '14']], [22, ['Ventura', '13']], [21, ['Monterey', '12']], [20, ['Big Sur', '11']], [19, ['Catalina', '10.15']], [18, ['Mojave', '10.14']], [17, ['High Sierra', '10.13']], [16, ['Sierra', '10.12']], [15, ['El Capitan', '10.11']], [14, ['Yosemite', '10.10']], [13, ['Mavericks', '10.9']], [12, ['Mountain Lion', '10.8']], [11, ['Lion', '10.7']], [10, ['Snow Leopard', '10.6']], [9, ['Leopard', '10.5']], [8, ['Tiger', '10.4']], [7, ['Panther', '10.3']], [6, ['Jaguar', '10.2']], [5, ['Puma', '10.1']], ]); export default function macosRelease(release) { release = Number((release || os.release()).split('.')[0]); const [name, version] = nameMap.get(release) || ['Unknown', '']; return { name, version, }; } macos-release-3.2.0/index.test-d.ts000066400000000000000000000003231443760247200171210ustar00rootroot00000000000000import {expectType} from 'tsd'; import macosRelease from './index.js'; expectType<{name: string; version: string}>(macosRelease()); expectType<{name: string; version: string} | undefined>(macosRelease('foo')); macos-release-3.2.0/license000066400000000000000000000021351443760247200156130ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. macos-release-3.2.0/package.json000066400000000000000000000014331443760247200165340ustar00rootroot00000000000000{ "name": "macos-release", "version": "3.2.0", "description": "Get the name and version of a macOS release from the Darwin version", "license": "MIT", "repository": "sindresorhus/macos-release", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "type": "module", "exports": "./index.js", "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "macos", "os", "darwin", "operating", "system", "platform", "name", "title", "release", "version" ], "devDependencies": { "ava": "^3.15.0", "tsd": "^0.17.0", "xo": "^0.44.0" } } macos-release-3.2.0/readme.md000066400000000000000000000034421443760247200160270ustar00rootroot00000000000000# macos-release > Get the name and version of a macOS release from the Darwin version\ > Example: `13.2.0` → `{name: 'Mavericks', version: '10.9'}` ## Install ``` $ npm install macos-release ``` ## Usage ```js import os from 'node:os'; import macosRelease from 'macos-release'; // On a macOS Sierra system macosRelease(); //=> {name: 'Sierra', version: '10.12'} os.release(); //=> 13.2.0 // This is the Darwin kernel version macosRelease(os.release()); //=> {name: 'Sierra', version: '10.12'} macosRelease('14.0.0'); //=> {name: 'Yosemite', version: '10.10'} macosRelease('20.0.0'); //=> {name: 'Big Sur', version: '11'} ``` ## API ### macosRelease(release?) #### release Type: `string` 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). ## Related - [os-name](https://github.com/sindresorhus/os-name) - Get the name of the current operating system. Example: `macOS Sierra` - [macos-version](https://github.com/sindresorhus/macos-version) - Get the macOS version of the current system. Example: `10.9.3` - [win-release](https://github.com/sindresorhus/win-release) - Get the name of a Windows version from the release number: `5.1.2600` → `XP` ---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
macos-release-3.2.0/test.js000066400000000000000000000005561443760247200155700ustar00rootroot00000000000000import test from 'ava'; import macosRelease from './index.js'; test('main', t => { t.deepEqual(macosRelease('13.2.0'), { name: 'Mavericks', version: '10.9', }); t.deepEqual(macosRelease('20.0.0'), { name: 'Big Sur', version: '11', }); }); test('unknown version', t => { t.deepEqual(macosRelease('4.0.0'), { name: 'Unknown', version: '', }); });