get-os-info
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

get-os-info

Get the name and version of the local OS

This package is based on the macos-release , windows-release and getos packages.

Install

$ npm install get-os-info

Usage

TypeScript

import getOSInfo, { OSInfo } from 'get-os-info'

const info: OSInfo | null = await getOSInfo();

if (info)
    console.log(info.name, info.version)

// Example:
// {
//   name: 'Windows',
//   version: '11'
// }

JavaScript

import { getOSInfo } from 'get-os-info';
//or
const { getOSInfo } = require('get-os-info');

const info = await getOSInfo();

Separate functions

import os from 'os'
import { getMacInfo, getWindowsInfo, getLinuxInfo } from "get-os-info";
//or
const os = require("os");
const { getMacInfo, getWindowsInfo, getLinuxInfo } = require('get-os-info')

const release = os.release(); //'10.0.22000'

getWindowsInfo(release).then(info => {
    if (info)
        console.log(info);
})
// {
//   name:    'Windows',
//   version: '11'
// }

console.log(await getWindowsInfo()) // Will be the same

NOTE: Currently it is not possible to pass a release version argument to the getLinuxInfo function.

Related


Readme

Keywords

none

Package Sidebar

Install

npm i get-os-info

Weekly Downloads

119,828

Version

1.0.2

License

ISC

Unpacked Size

8.98 kB

Total Files

10

Last publish

Collaborators

  • artem-babich