getos
Advanced tools
Comparing version 2.8.4 to 3.0.0
35
index.js
@@ -62,3 +62,3 @@ /** | ||
if(candidates.length===1) { | ||
return customLogic(os,file,function(e,os) { | ||
return customLogic(os,getName(os.dist),file,function(e,os) { | ||
if(e) return cb(e) | ||
@@ -82,11 +82,6 @@ cachedDistro = os | ||
async.each(candidates, function(candidate, done) { | ||
/** | ||
* We only care about the first word. I.E. for Arch Linux it is safe | ||
* to simply search for "arch". Also note, we force lower case to | ||
* match file.toLowerCase() above. | ||
*/ | ||
check = candidate.split(" ")[0].toLowerCase() | ||
if(file.indexOf(check)>=0) { | ||
var name = getName(candidate); | ||
if(file.indexOf(name)>=0) { | ||
os.dist = candidate | ||
return customLogic(os,file,function(e, augmentedOs) { | ||
return customLogic(os,name,file,function(e, augmentedOs) { | ||
if(e) return done(e) | ||
@@ -109,7 +104,25 @@ os = augmentedOs; | ||
function getName(candidate) { | ||
/** | ||
* We only care about the first word. I.E. for Arch Linux it is safe | ||
* to simply search for "arch". Also note, we force lower case to | ||
* match file.toLowerCase() above. | ||
*/ | ||
var index = 0 | ||
var name = 'linux' | ||
/** | ||
* Don't include 'linux' when searching since it is too aggressive when | ||
* matching (see #54) | ||
*/ | ||
while(name === 'linux') { | ||
name = candidate.split(" ")[index++].toLowerCase() | ||
} | ||
return name; | ||
} | ||
/** | ||
* Loads a custom logic module to populate additional distribution information | ||
*/ | ||
function customLogic(os,file,cb) { | ||
try{require("./logic/"+os.dist.split(" ")[0].toLowerCase()+".js")(os,file,cb)} | ||
function customLogic(os,name,file,cb) { | ||
try{require("./logic/"+name+".js")(os,file,cb)} | ||
catch(e) {cb(null,os)} | ||
@@ -116,0 +129,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
"/etc/SuSE-release": ["SUSE Linux"], | ||
"/etc/lsb-release" : ["Ubuntu Linux","Chakra","IYCC","Linux Mint","elementary OS"], | ||
"/etc/lsb-release" : ["Ubuntu Linux","Chakra","IYCC","Linux Mint","elementary OS","Arch Linux"], | ||
"/etc/debian_version" : ["Debian"], | ||
@@ -9,0 +9,0 @@ "/etc/debian_release" : ["Debian"], |
{ | ||
"name": "getos", | ||
"version": "2.8.4", | ||
"version": "3.0.0", | ||
"description": "Get the OS/Distribution name of the environment you are working on", | ||
@@ -26,3 +26,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"cli-color": "1.1.0", | ||
"cli-color": "1.2.0", | ||
"execSync": "1.0.2", | ||
@@ -32,3 +32,3 @@ "tape": "4.6.3" | ||
"dependencies": { | ||
"async": "2.1.4" | ||
"async": "2.3.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "contributors": [ |
@@ -5,3 +5,3 @@ # getos | ||
[![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/dt/getos.svg) ![](https://img.shields.io/npm/v/getos.svg) ![](https://img.shields.io/npm/l/express.svg) ![](https://img.shields.io/twitter/url/https/github.com/retrohacker/getos.svg?style=social) | ||
[![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) | ||
@@ -8,0 +8,0 @@ [![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/) |
@@ -25,3 +25,4 @@ [ | ||
, { "desc": "Amazon Linux", "platform": "linux", "file": { "/etc/system-release": "Amazon Linux AMI release 2016.03"}, "expected": {"dist": "Amazon Linux", "os": "linux", "release": "2016.03"}} | ||
, { "desc": "Arch Linux", "platform": "linux", "file": { "/etc/lsb-release": "LSB_VERSION=1.4\nDISTRIB_ID=Arch\nDISTRIB_RELEASE=rolling\nDISTRIB_DESCRIPTION=\"Arch Linux\""}, "expected": {"dist": "Arch Linux", "os": "linux", "release": "rolling"}} | ||
, { "desc": "Linux Mint", "platform": "linux", "file": { "/etc/lsb-release": "DISTRIB_ID=LinuxMint\nDISTRIB_RELEASE=18\nDISTRIB_CODENAME=sarah\nDISTRIB_DESCRIPTION=\"Linux Mint 18 Sarah\""}, "expected": {"dist": "Linux Mint", "os": "linux", "codename": "sarah", "release": "18"}} | ||
] |
@@ -44,3 +44,3 @@ var test = require('tape') | ||
t.error(err, 'no error') | ||
t.deepEqual(data.expected, os, 'correct os data') | ||
t.deepEqual(os, data.expected, 'correct os data') | ||
t.end() | ||
@@ -47,0 +47,0 @@ }) |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
36910
408
+ Addedasync@2.3.0(transitive)
- Removedasync@2.1.4(transitive)
Updatedasync@2.3.0