is-path-global
Advanced tools
Comparing version
13
index.js
'use strict'; | ||
const path = require('path'); | ||
const isPathInside = require('is-path-inside'); | ||
var delimiter = require('path').delimiter; | ||
var isPathInside = require('is-path-inside'); | ||
module.exports = function (str) { | ||
module.exports = str => { | ||
if (typeof str !== 'string') { | ||
throw new TypeError('Expected a string'); | ||
throw new TypeError(`Expected a \`string\`, got \`${typeof str}\``); | ||
} | ||
return process.env.PATH.split(delimiter).some(function (path) { | ||
return isPathInside(str, path) || str === path; | ||
}); | ||
return process.env.PATH.split(path.delimiter).some(pth => isPathInside(str, pth) || str === pth); | ||
}; |
{ | ||
"name": "is-path-global", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "Check if a path is in PATH", | ||
@@ -13,6 +13,6 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "xo && ava" | ||
}, | ||
@@ -37,4 +37,8 @@ "files": [ | ||
"devDependencies": { | ||
"ava": "^0.0.4" | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
@@ -16,3 +16,3 @@ # is-path-global [](https://travis-ci.org/kevva/is-path-global) | ||
```js | ||
var isPathGlobal = require('is-path-global'); | ||
const isPathGlobal = require('is-path-global'); | ||
@@ -19,0 +19,0 @@ isPathGlobal('/bin/sh'); |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2592
1.65%2
100%9
-18.18%1
Infinity%