Skip to content

Artem-Babich/get-os-info

Repository files navigation

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


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published