From 1bfd8d3a923f49dcd796291814784fabe7f0aea8 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 11 Nov 2021 18:50:33 +0700 Subject: [PATCH] Fix Windows 11 check Fixes #15 --- index.js | 4 ++++ index.test-d.ts | 2 +- package.json | 10 +++++----- readme.md | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index ec4a55f..b89cd46 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,10 @@ export default function osName(platform, release) { try { id = release ? macosRelease(release).name : ''; + + if (id === 'Unknown') { + return prefix; + } } catch {} return prefix + (id ? ' ' + id : ''); diff --git a/index.test-d.ts b/index.test-d.ts index 5973384..ee6ef7d 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -3,7 +3,7 @@ import {expectType} from 'tsd'; import osName from './index.js'; expectType(osName()); -expectType(osName(os.platform(), os.release())); // eslint-disable-line @typescript-eslint/no-unsafe-member-access +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')); diff --git a/package.json b/package.json index a55e9ca..4442ce7 100644 --- a/package.json +++ b/package.json @@ -36,13 +36,13 @@ "linux" ], "dependencies": { - "macos-release": "^3.0.0", - "windows-release": "^5.0.0" + "macos-release": "^3.0.1", + "windows-release": "^5.0.1" }, "devDependencies": { - "@types/node": "^16.6.0", + "@types/node": "^16.11.7", "ava": "^3.15.0", - "tsd": "^0.17.0", - "xo": "^0.44.0" + "tsd": "^0.18.0", + "xo": "^0.46.4" } } diff --git a/readme.md b/readme.md index 965c532..f505414 100644 --- a/readme.md +++ b/readme.md @@ -7,8 +7,8 @@ Useful for analytics and debugging. ## Install -``` -$ npm install os-name +```sh +npm install os-name ``` ## Usage