first commit
This commit is contained in:
28
node_modules/windows-release/index.d.ts
generated
vendored
Normal file
28
node_modules/windows-release/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
Get the name of a Windows version from the release number: `5.1.2600` → `XP`.
|
||||
|
||||
@param release - By default, the current OS is used, but you can supply a custom release number, which is the output of [`os.release()`](https://nodejs.org/api/os.html#os_os_release).
|
||||
|
||||
Note: Most Windows Server versions cannot be detected based on the release number alone. There is runtime detection in place to work around this, but it will only be used if no argument is supplied, or the supplied argument matches `os.release()`.
|
||||
|
||||
@example
|
||||
```
|
||||
import os from 'node:os';
|
||||
import windowsRelease from 'windows-release';
|
||||
|
||||
// On a Windows XP system
|
||||
|
||||
windowsRelease();
|
||||
//=> 'XP'
|
||||
|
||||
os.release();
|
||||
//=> '5.1.2600'
|
||||
|
||||
windowsRelease(os.release());
|
||||
//=> 'XP'
|
||||
|
||||
windowsRelease('4.9.3000');
|
||||
//=> 'ME'
|
||||
```
|
||||
*/
|
||||
export default function windowsRelease(release?: string): string;
|
||||
58
node_modules/windows-release/index.js
generated
vendored
Normal file
58
node_modules/windows-release/index.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import os from 'node:os';
|
||||
import {execaSync} from 'execa';
|
||||
|
||||
// Reference: https://www.gaijin.at/en/lstwinver.php
|
||||
// Windows 11 reference: https://docs.microsoft.com/en-us/windows/release-health/windows11-release-information
|
||||
const names = new Map([
|
||||
['10.0.2', '11'], // It's unclear whether future Windows 11 versions will use this version scheme: https://github.com/sindresorhus/windows-release/pull/26/files#r744945281
|
||||
['10.0', '10'],
|
||||
['6.3', '8.1'],
|
||||
['6.2', '8'],
|
||||
['6.1', '7'],
|
||||
['6.0', 'Vista'],
|
||||
['5.2', 'Server 2003'],
|
||||
['5.1', 'XP'],
|
||||
['5.0', '2000'],
|
||||
['4.90', 'ME'],
|
||||
['4.10', '98'],
|
||||
['4.03', '95'],
|
||||
['4.00', '95'],
|
||||
]);
|
||||
|
||||
export default function windowsRelease(release) {
|
||||
const version = /(\d+\.\d+)(?:\.(\d+))?/.exec(release || os.release());
|
||||
|
||||
if (release && !version) {
|
||||
throw new Error('`release` argument doesn\'t match `n.n`');
|
||||
}
|
||||
|
||||
let ver = version[1] || '';
|
||||
const build = version[2] || '';
|
||||
|
||||
// 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 `wmic` is obsolete (later versions of Windows 10), use PowerShell instead.
|
||||
// If the resulting caption contains the year 2008, 2012, 2016, 2019 or 2022, 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)) {
|
||||
let stdout;
|
||||
try {
|
||||
stdout = execaSync('wmic', ['os', 'get', 'Caption']).stdout || '';
|
||||
} catch {
|
||||
stdout = execaSync('powershell', ['(Get-CimInstance -ClassName Win32_OperatingSystem).caption']).stdout || '';
|
||||
}
|
||||
|
||||
const year = (stdout.match(/2008|2012|2016|2019|2022|2025/) || [])[0];
|
||||
|
||||
if (year) {
|
||||
return `Server ${year}`;
|
||||
}
|
||||
}
|
||||
|
||||
// Windows 11
|
||||
if (ver === '10.0' && build.startsWith('2')) {
|
||||
ver = '10.0.2';
|
||||
}
|
||||
|
||||
return names.get(ver);
|
||||
}
|
||||
9
node_modules/windows-release/license
generated
vendored
Normal file
9
node_modules/windows-release/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.
|
||||
50
node_modules/windows-release/package.json
generated
vendored
Normal file
50
node_modules/windows-release/package.json
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "windows-release",
|
||||
"version": "6.1.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": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"os",
|
||||
"win",
|
||||
"win32",
|
||||
"windows",
|
||||
"operating",
|
||||
"system",
|
||||
"platform",
|
||||
"name",
|
||||
"title",
|
||||
"release",
|
||||
"version"
|
||||
],
|
||||
"dependencies": {
|
||||
"execa": "^8.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^5.3.1",
|
||||
"tsd": "^0.29.0",
|
||||
"xo": "^0.56.0"
|
||||
}
|
||||
}
|
||||
47
node_modules/windows-release/readme.md
generated
vendored
Normal file
47
node_modules/windows-release/readme.md
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# windows-release
|
||||
|
||||
> Get the name of a Windows version from the release number: `5.1.2600` → `XP`
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install windows-release
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import os from 'node:os';
|
||||
import windowsRelease from 'windows-release';
|
||||
|
||||
// On a Windows XP system
|
||||
|
||||
windowsRelease();
|
||||
//=> 'XP'
|
||||
|
||||
os.release();
|
||||
//=> '5.1.2600'
|
||||
|
||||
windowsRelease(os.release());
|
||||
//=> 'XP'
|
||||
|
||||
windowsRelease('4.9.3000');
|
||||
//=> 'ME'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### windowsRelease(release?)
|
||||
|
||||
#### release
|
||||
|
||||
Type: `string`
|
||||
|
||||
By default, the current OS is used, but you can supply a custom release number, which is the output of [`os.release()`](https://nodejs.org/api/os.html#os_os_release).
|
||||
|
||||
Note: Most Windows Server versions cannot be detected based on the release number alone. There is runtime detection in place to work around this, but it will only be used if no argument is supplied, or the supplied argument matches `os.release()`.
|
||||
|
||||
## Related
|
||||
|
||||
- [os-name](https://github.com/sindresorhus/os-name) - Get the name of the current operating system
|
||||
- [macos-release](https://github.com/sindresorhus/macos-release) - Get the name and version of a macOS release from the Darwin version
|
||||
Reference in New Issue
Block a user