Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/retrohacker/getos

A Node.js module that returns the OS/Distribution name of the environment you are working on
https://github.com/retrohacker/getos

Last synced: 3 days ago
JSON representation

A Node.js module that returns the OS/Distribution name of the environment you are working on

Awesome Lists containing this project

README

        

# getos

[![Greenkeeper badge](https://badges.greenkeeper.io/retrohacker/getos.svg)](https://greenkeeper.io/)

![getos](./imgs/logo.png)

[![Build Status](https://travis-ci.org/retrohacker/getos.png?branch=master)](https://travis-ci.org/retrohacker/getos) ![](https://img.shields.io/github/issues/retrohacker/getos.svg) ![](https://img.shields.io/npm/dm/getos.svg) ![](https://img.shields.io/npm/v/getos.svg) ![](https://img.shields.io/npm/l/getos.svg) ![](https://img.shields.io/twitter/url/https/github.com/retrohacker/getos.svg?style=social)

[![NPM](https://nodei.co/npm/getos.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/getos/)[![NPM](https://nodei.co/npm-dl/getos.png?months=9&height=3)](https://nodei.co/npm/getos/)

[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

Get the OS/Distribution name of the environment you are working on

## Problem

`os.platform()` returns `linux`. If you want the distrubtion name, you're out of luck.

## Solution

This. Simply call:

```js
var getos = require('getos')

getos(function(e,os) {
if(e) return console.log(e)
console.log("Your OS is:" +JSON.stringify(os))
})
```

The `os` object conforms to:

```js
{
os: [OS NAME],
dist:[DIST NAME],
codename:[CODENAME],
release:[VERSION]
}
```

For example:

```js
{
os: "linux",
dist: "Ubuntu",
codename: "precise",
release: "12.04"
}
```

## Disclaimer
Check `os.json` in this repo. Any distribution that *shares* a common resource file with another distrubtion is currently untested. These are the arrays of distrubitons with more than 1 member. If you are using one of these distrubtions, please submit an issue letting me know if it works. If it fails, please post the content of the file.

If you have a distrubtion *not* in `os.json`, please identify your resource file and submit it's name and content along with your distrbution/version in an issue.

Thanks for helping make this tool great.

## Unit Tests

Unit tests stub out the behaviour of the OS files and libraries we depend on to ensure the behaviour of the application is sound. You can run these simply by running `npm test`

## Authors and Contributors

getos has been made possible by these fantastic contributors:

Benjamin E. CoeGitHub/bcoeTwitter/@benjamincoe
Eugene SharyginGitHub/eush77Twitter/@eush77
David RouthieauGitHub/root-iounknown
LawrenceGitHub/mindmeltingTwitter/@mindmelting
Roman JurkovGitHub/winfinitTwitter/@winfinit
Rod VaggGitHub/rvaggTwitter/@rvagg
Zeke SikelianosGitHub/zekeTwitter/@zeke
AlexanderGitHub/alex4ZeroTwitter/@alex4Zero