1 | import type {Options} from '../arguments/options.js';
|
2 | import type {ResultPromise} from '../subprocess/subprocess.js';
|
3 | import type {TemplateString} from './template.js';
|
4 |
|
5 | /**
|
6 | Same as `execa()` but using the `node: true` option.
|
7 | Executes a Node.js file using `node scriptPath ...arguments`.
|
8 |
|
9 | When `command` is a template string, it includes both the `file` and its `arguments`.
|
10 |
|
11 | `execaNode(options)` can be used to return a new instance of this method but with different default `options`. Consecutive calls are merged to previous ones.
|
12 |
|
13 | This is the preferred method when executing Node.js files.
|
14 |
|
15 | @param scriptPath - Node.js script to execute, as a string or file URL
|
16 | @param arguments - Arguments to pass to `scriptPath` on execution.
|
17 | @returns A `ResultPromise` that is both:
|
18 | - the subprocess.
|
19 | - a `Promise` either resolving with its successful `result`, or rejecting with its `error`.
|
20 | @throws `ExecaError`
|
21 |
|
22 | @example
|
23 | ```
|
24 | import {execaNode, execa} from 'execa';
|
25 |
|
26 | await execaNode`file.js argument`;
|
27 | // Is the same as:
|
28 | await execa({node: true})`file.js argument`;
|
29 | // Or:
|
30 | await execa`node file.js argument`;
|
31 | ```
|
32 | */
|
33 | export declare const execaNode: ExecaNodeMethod<{}>;
|
34 |
|
35 | /**
|
36 | `execaNode()` method either exported by Execa, or bound using `execaNode(options)`.
|
37 | */
|
38 | export type ExecaNodeMethod<OptionsType extends Options = Options> =
|
39 | & ExecaNodeBind<OptionsType>
|
40 | & ExecaNodeTemplate<OptionsType>
|
41 | & ExecaNodeArrayLong<OptionsType>
|
42 | & ExecaNodeArrayShort<OptionsType>;
|
43 |
|
44 | // `execaNode(options)` binding
|
45 | type ExecaNodeBind<OptionsType extends Options> =
|
46 | <NewOptionsType extends Options = {}>(options: NewOptionsType)
|
47 | => ExecaNodeMethod<OptionsType & NewOptionsType>;
|
48 |
|
49 | // `execaNode`command`` template syntax
|
50 | type ExecaNodeTemplate<OptionsType extends Options> =
|
51 | (...templateString: TemplateString)
|
52 | => ResultPromise<OptionsType>;
|
53 |
|
54 | // `execaNode('script', ['argument'], {})` array syntax
|
55 | type ExecaNodeArrayLong<OptionsType extends Options> =
|
56 | <NewOptionsType extends Options = {}>(scriptPath: string | URL, arguments?: readonly string[], options?: NewOptionsType)
|
57 | => ResultPromise<OptionsType & NewOptionsType>;
|
58 |
|
59 | // `execaNode('script', {})` array syntax
|
60 | type ExecaNodeArrayShort<OptionsType extends Options> =
|
61 | <NewOptionsType extends Options = {}>(scriptPath: string | URL, options?: NewOptionsType)
|
62 | => ResultPromise<OptionsType & NewOptionsType>;
|