time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

index.d.ts (2261B)


      1 export interface RunPathOptions {
      2 	/**
      3 	Working directory.
      4 
      5 	@default process.cwd()
      6 	*/
      7 	readonly cwd?: string | URL;
      8 
      9 	/**
     10 	PATH to be appended. Default: [`PATH`](https://github.com/sindresorhus/path-key).
     11 
     12 	Set it to an empty string to exclude the default PATH.
     13 	*/
     14 	readonly path?: string;
     15 
     16 	/**
     17 	Path to the Node.js executable to use in child processes if that is different from the current one. Its directory is pushed to the front of PATH.
     18 
     19 	This can be either an absolute path or a path relative to the `cwd` option.
     20 
     21 	@default process.execPath
     22 	*/
     23 	readonly execPath?: string;
     24 }
     25 
     26 export type ProcessEnv = Record<string, string | undefined>;
     27 
     28 export interface EnvOptions {
     29 	/**
     30 	The working directory.
     31 
     32 	@default process.cwd()
     33 	*/
     34 	readonly cwd?: string | URL;
     35 
     36 	/**
     37 	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.
     38 	*/
     39 	readonly env?: ProcessEnv;
     40 
     41 	/**
     42 	The path to the current Node.js executable. Its directory is pushed to the front of PATH.
     43 
     44 	This can be either an absolute path or a path relative to the `cwd` option.
     45 
     46 	@default process.execPath
     47 	*/
     48 	readonly execPath?: string;
     49 }
     50 
     51 /**
     52 Get your [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) prepended with locally installed binaries.
     53 
     54 @returns The augmented path string.
     55 
     56 @example
     57 ```
     58 import childProcess from 'node:child_process';
     59 import {npmRunPath} from 'npm-run-path';
     60 
     61 console.log(process.env.PATH);
     62 //=> '/usr/local/bin'
     63 
     64 console.log(npmRunPath());
     65 //=> '/Users/sindresorhus/dev/foo/node_modules/.bin:/Users/sindresorhus/dev/node_modules/.bin:/Users/sindresorhus/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/bin'
     66 ```
     67 */
     68 export function npmRunPath(options?: RunPathOptions): string;
     69 
     70 /**
     71 @returns The augmented [`process.env`](https://nodejs.org/api/process.html#process_process_env) object.
     72 
     73 @example
     74 ```
     75 import childProcess from 'node:child_process';
     76 import {npmRunPathEnv} from 'npm-run-path';
     77 
     78 // `foo` is a locally installed binary
     79 childProcess.execFileSync('foo', {
     80 	env: npmRunPathEnv()
     81 });
     82 ```
     83 */
     84 export function npmRunPathEnv(options?: EnvOptions): ProcessEnv;