mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #32092 from BendingBender/npm-run-path
[npm-run-path] Add types
This commit is contained in:
Vendored
+45
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
});
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user