-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 8, add TypeScript definition (#4)
- Loading branch information
1 parent
4d95631
commit 15717af
Showing
11 changed files
with
146 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- '6' | ||
- '4' | ||
- '10' | ||
- '8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
export interface RunPathOptions { | ||
/** | ||
* Working directory. | ||
* | ||
* @default process.cwd() | ||
*/ | ||
readonly cwd?: string; | ||
|
||
/** | ||
* PATH to be appended. Default: [`PATH`](https://github.com/sindresorhus/path-key). | ||
* | ||
* Set it to an empty string to exclude the default PATH. | ||
*/ | ||
readonly path?: string; | ||
} | ||
|
||
export interface ProcessEnv { | ||
[key: string]: string | undefined; | ||
} | ||
|
||
export interface EnvOptions { | ||
/** | ||
* Working directory. | ||
* | ||
* @default process.cwd() | ||
*/ | ||
readonly cwd?: string; | ||
|
||
/** | ||
* Accepts an object of environment variables, like `process.env`, and modifies the PATH using the correct [PATH key](https://github.com/sindresorhus/path-key). Use this if you're modifying the PATH for use in the `child_process` options. | ||
*/ | ||
readonly env?: ProcessEnv; | ||
} | ||
|
||
/** | ||
* Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries. | ||
*/ | ||
declare const npmRunPath: { | ||
/** | ||
* Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries. | ||
* | ||
* @returns The augmented path string. | ||
*/ | ||
(options?: RunPathOptions): string; | ||
|
||
/** | ||
* @returns The augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object. | ||
*/ | ||
env(options?: EnvOptions): ProcessEnv; | ||
}; | ||
|
||
export default npmRunPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {expectType} from 'tsd-check'; | ||
import npmRunPath, {ProcessEnv} from '.'; | ||
|
||
expectType<string>(npmRunPath()); | ||
expectType<string>(npmRunPath({cwd: '/foo'})); | ||
expectType<string>(npmRunPath({path: '/usr/local/bin'})); | ||
|
||
expectType<ProcessEnv>(npmRunPath.env()); | ||
expectType<ProcessEnv>(npmRunPath.env({cwd: '/foo'})); | ||
expectType<ProcessEnv>(npmRunPath.env({env: process.env})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,44 @@ | ||
{ | ||
"name": "npm-run-path", | ||
"version": "2.0.2", | ||
"description": "Get your PATH prepended with locally installed binaries", | ||
"license": "MIT", | ||
"repository": "sindresorhus/npm-run-path", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"npm", | ||
"run", | ||
"path", | ||
"package", | ||
"bin", | ||
"binary", | ||
"binaries", | ||
"script", | ||
"cli", | ||
"command-line", | ||
"execute", | ||
"executable" | ||
], | ||
"dependencies": { | ||
"path-key": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "npm-run-path", | ||
"version": "2.0.2", | ||
"description": "Get your PATH prepended with locally installed binaries", | ||
"license": "MIT", | ||
"repository": "sindresorhus/npm-run-path", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"npm", | ||
"run", | ||
"path", | ||
"package", | ||
"bin", | ||
"binary", | ||
"binaries", | ||
"script", | ||
"cli", | ||
"command-line", | ||
"execute", | ||
"executable" | ||
], | ||
"dependencies": { | ||
"path-key": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.3.1", | ||
"tsd-check": "^0.3.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import path from 'path'; | ||
import test from 'ava'; | ||
import m from './'; | ||
import npmRunPath from '.'; | ||
|
||
test(t => { | ||
test('npmRunPath', t => { | ||
t.is( | ||
m({path: ''}).split(path.delimiter)[0], | ||
npmRunPath({path: ''}).split(path.delimiter)[0], | ||
path.join(__dirname, 'node_modules/.bin') | ||
); | ||
t.is( | ||
m.env({env: {PATH: 'foo'}}).PATH.split(path.delimiter)[0], | ||
npmRunPath.env({env: {PATH: 'foo'}}).PATH.split(path.delimiter)[0], | ||
path.join(__dirname, 'node_modules/.bin') | ||
); | ||
}); |