pax_global_header00006660000000000000000000000064143441103060014506gustar00rootroot0000000000000052 comment=ff7af806e5bb960867924bf7fbbbadd801e06b0b os-name-5.1.0/000077500000000000000000000000001434411030600130505ustar00rootroot00000000000000os-name-5.1.0/.editorconfig000066400000000000000000000002571434411030600155310ustar00rootroot00000000000000root = 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 os-name-5.1.0/.gitattributes000066400000000000000000000000231434411030600157360ustar00rootroot00000000000000* text=auto eol=lf os-name-5.1.0/.github/000077500000000000000000000000001434411030600144105ustar00rootroot00000000000000os-name-5.1.0/.github/funding.yml000066400000000000000000000001611434411030600165630ustar00rootroot00000000000000github: sindresorhus open_collective: sindresorhus custom: https://sindresorhus.com/donate tidelift: npm/os-name os-name-5.1.0/.github/security.md000066400000000000000000000002631434411030600166020ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. os-name-5.1.0/.github/workflows/000077500000000000000000000000001434411030600164455ustar00rootroot00000000000000os-name-5.1.0/.github/workflows/main.yml000066400000000000000000000006261434411030600201200ustar00rootroot00000000000000name: 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 os-name-5.1.0/.gitignore000066400000000000000000000000271434411030600150370ustar00rootroot00000000000000node_modules yarn.lock os-name-5.1.0/.npmrc000066400000000000000000000000231434411030600141630ustar00rootroot00000000000000package-lock=false os-name-5.1.0/index.d.ts000066400000000000000000000012411434411030600147470ustar00rootroot00000000000000/** Get the name of the current operating system. By default, the name of the current operating system is returned. @param platform - Custom platform name. @param release - Custom release name. @example ``` import os from 'node:os'; import osName from 'os-name'; // On a macOS Sierra system osName(); //=> 'macOS Sierra' osName(os.platform(), os.release()); //=> 'macOS Sierra' osName('darwin', '14.0.0'); //=> 'OS X Yosemite' osName('linux', '3.13.0-24-generic'); //=> 'Linux 3.13' osName('win32', '6.3.9600'); //=> 'Windows 8.1' ``` */ export default function osName(): string; export default function osName(platform: NodeJS.Platform, release: string): string; os-name-5.1.0/index.js000066400000000000000000000021701434411030600145150ustar00rootroot00000000000000import os from 'node:os'; import macosRelease from 'macos-release'; import windowsRelease from 'windows-release'; export default function osName(platform, release) { if (!platform && release) { throw new Error('You can\'t specify a `release` without specifying `platform`'); } platform = platform || os.platform(); let id; if (platform === 'darwin') { if (!release && os.platform() === 'darwin') { release = os.release(); } const prefix = release ? (Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X') : 'macOS'; try { id = release ? macosRelease(release).name : ''; if (id === 'Unknown') { return prefix; } } catch {} return prefix + (id ? ' ' + id : ''); } if (platform === 'linux') { if (!release && os.platform() === 'linux') { release = os.release(); } id = release ? release.replace(/^(\d+\.\d+).*/, '$1') : ''; return 'Linux' + (id ? ' ' + id : ''); } if (platform === 'win32') { if (!release && os.platform() === 'win32') { release = os.release(); } id = release ? windowsRelease(release) : ''; return 'Windows' + (id ? ' ' + id : ''); } return platform; } os-name-5.1.0/index.test-d.ts000066400000000000000000000005161434411030600157300ustar00rootroot00000000000000import os from 'node:os'; import {expectType} from 'tsd'; import osName from './index.js'; expectType(osName()); expectType(osName(os.platform(), os.release())); expectType(osName('darwin', '14.0.0')); expectType(osName('linux', '3.13.0-24-generic')); expectType(osName('win32', '6.3.9600')); os-name-5.1.0/license000066400000000000000000000021351434411030600144160ustar00rootroot00000000000000MIT 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. os-name-5.1.0/package.json000066400000000000000000000016121434411030600153360ustar00rootroot00000000000000{ "name": "os-name", "version": "5.1.0", "description": "Get the name of the current operating system. Example: macOS Sierra", "license": "MIT", "repository": "sindresorhus/os-name", "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": [ "os", "operating", "system", "platform", "name", "title", "release", "version", "macos", "windows", "linux" ], "dependencies": { "macos-release": "^3.1.0", "windows-release": "^5.0.1" }, "devDependencies": { "@types/node": "^16.11.7", "ava": "^3.15.0", "tsd": "^0.18.0", "xo": "^0.46.4" } } os-name-5.1.0/readme.md000066400000000000000000000031321434411030600146260ustar00rootroot00000000000000# os-name > Get the name of the current operating system\ > Example: `macOS Sierra` Useful for analytics and debugging. ## Install ```sh npm install os-name ``` ## Usage ```js import os from 'node:os'; import osName from 'os-name'; // On a macOS Sierra system osName(); //=> 'macOS Sierra' osName(os.platform(), os.release()); //=> 'macOS Sierra' osName('darwin', '14.0.0'); //=> 'OS X Yosemite' osName('linux', '3.13.0-24-generic'); //=> 'Linux 3.13' osName('win32', '6.3.9600'); //=> 'Windows 8.1' ``` ## API ### osName(platform?, release?) By default, the name of the current operating system is returned. You can optionally supply a custom [`os.platform()`](https://nodejs.org/api/os.html#os_os_platform) and [`os.release()`](https://nodejs.org/api/os.html#os_os_release). Check out [`getos`](https://github.com/wblankenship/getos) if you need the Linux distribution name. ## Contributing Production systems depend on this package for logging / tracking. Please be careful when introducing new output, and adhere to existing output format (whitespace, capitalization, etc.). ## Related - [os-name-cli](https://github.com/sindresorhus/os-name-cli) - CLI for this module ---
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.
os-name-5.1.0/test.js000066400000000000000000000016471434411030600143750ustar00rootroot00000000000000import os from 'node:os'; import test from 'ava'; import osName from './index.js'; test('main', t => { t.true(osName().length > 0); t.is(osName('darwin', '18.0.0'), 'macOS Mojave'); t.is(osName('darwin', '17.0.0'), 'macOS High Sierra'); t.is(osName('darwin', '16.0.0'), 'macOS Sierra'); t.is(osName('darwin', '14.0.0'), 'OS X Yosemite'); t.is(osName('darwin', '99.0.0'), 'macOS'); t.is(osName('linux', '3.13.0-24-generic'), 'Linux 3.13'); t.is(osName('win32', '5.1.2600'), 'Windows XP'); t.is(osName('win32', '4.90'), 'Windows ME'); t.is(osName('win32', '6.2'), 'Windows 8'); t.is(osName('win32', '10.0'), 'Windows 10'); os.platform = () => 'darwin'; t.is(osName('win32'), 'Windows'); t.is(osName('linux'), 'Linux'); os.platform = () => 'linux'; t.is(osName('darwin'), 'macOS'); t.is(osName('win32'), 'Windows'); os.platform = () => 'win32'; t.is(osName('darwin'), 'macOS'); t.is(osName('linux'), 'Linux'); });