Merge pull request #32092 from BendingBender/npm-run-path

[npm-run-path] Add types
This commit is contained in:
Daniel Rosenwasser
2019-01-14 14:25:28 -08:00
committed by GitHub
4 changed files with 85 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
// Type definitions for npm-run-path 2.0
// Project: https://github.com/sindresorhus/npm-run-path#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = npmRunPath;
/**
* Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries.
*/
declare function npmRunPath(options?: npmRunPath.Options): string;
declare namespace npmRunPath {
function env(options?: EnvOptions): ProcessEnv;
interface Options {
/**
* Working directory.
*/
cwd?: string;
/**
* PATH to be appended.
* Set it to an empty string to exclude the default [PATH](https://github.com/sindresorhus/path-key).
* @default PATH
*/
path?: string;
}
interface EnvOptions {
/**
* Working directory.
*/
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.
*/
env?: ProcessEnv;
}
interface ProcessEnv {
[key: string]: string | undefined;
}
}
+16
View File
@@ -0,0 +1,16 @@
/// <reference types="node" />
import childProcess = require('child_process');
import npmRunPath = require('npm-run-path');
npmRunPath(); // $ExpectType string
npmRunPath({ cwd: '/foo' }); // $ExpectType string
npmRunPath({ path: '/usr/local/bin' }); // $ExpectType string
npmRunPath.env(); // $ExpectType ProcessEnv
npmRunPath.env({ cwd: '/foo' }); // $ExpectType ProcessEnv
npmRunPath.env({ env: process.env }); // $ExpectType ProcessEnv
childProcess.execFileSync('foo', {
env: npmRunPath.env(),
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"npm-run-path-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }