windows-release
Advanced tools
Comparing version 3.2.0 to 3.3.0
16
index.js
@@ -29,9 +29,17 @@ 'use strict'; | ||
// Server 2008, 2012 and 2016 versions are ambiguous with desktop versions and must be detected at runtime. | ||
// Server 2008, 2012, 2016, and 2019 versions are ambiguous with desktop versions and must be detected at runtime. | ||
// If `release` is omitted or we're on a Windows system, and the version number is an ambiguous version | ||
// then use `wmic` to get the OS caption: https://msdn.microsoft.com/en-us/library/aa394531(v=vs.85).aspx | ||
// If the resulting caption contains the year 2008, 2012 or 2016, it is a server version, so return a server OS name. | ||
// If `wmic` is obsoloete (later versions of Windows 10), use PowerShell instead. | ||
// If the resulting caption contains the year 2008, 2012, 2016 or 2019, it is a server version, so return a server OS name. | ||
if ((!release || release === os.release()) && ['6.1', '6.2', '6.3', '10.0'].includes(ver)) { | ||
const stdout = execa.sync('wmic', ['os', 'get', 'Caption']).stdout || ''; | ||
const year = (stdout.match(/2008|2012|2016/) || [])[0]; | ||
let stdout; | ||
try { | ||
stdout = execa.sync('powershell', ['(Get-CimInstance -ClassName Win32_OperatingSystem).caption']).stdout || ''; | ||
} catch (_) { | ||
stdout = execa.sync('wmic', ['os', 'get', 'Caption']).stdout || ''; | ||
} | ||
const year = (stdout.match(/2008|2012|2016|2019/) || [])[0]; | ||
if (year) { | ||
@@ -38,0 +46,0 @@ return `Server ${year}`; |
{ | ||
"name": "windows-release", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Get the name of a Windows version from the release number: `5.1.2600` → `XP`", | ||
"license": "MIT", | ||
"repository": "sindresorhus/windows-release", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
@@ -12,0 +13,0 @@ "engines": { |
@@ -5,3 +5,2 @@ # windows-release [![Build Status](https://travis-ci.org/sindresorhus/windows-release.svg?branch=master)](https://travis-ci.org/sindresorhus/windows-release) | ||
## Install | ||
@@ -13,3 +12,2 @@ | ||
## Usage | ||
@@ -36,6 +34,5 @@ | ||
## API | ||
### windowsRelease([release]) | ||
### windowsRelease(release?) | ||
@@ -50,3 +47,2 @@ #### release | ||
## Related | ||
@@ -57,5 +53,12 @@ | ||
--- | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-windows-release?utm_source=npm-windows-release&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a> | ||
</b> | ||
<br> | ||
<sub> | ||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies. | ||
</sub> | ||
</div> |
Sorry, the diff of this file is not supported yet
6111
64
60