get-os-info
This library allows you to get a correct OS name and version
Last updated 5 years ago by artem-babich .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install get-os-info 
SYNC missed versions from official npm registry.

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


Current Tags

  • 1.0.2                                ...           latest (5 years ago)

2 Versions

  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Total 6
Today 0
This Week 6
This Month 6
Last Day 1
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (12)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE