-
-
Notifications
You must be signed in to change notification settings - Fork 0
The same as spawn(), but it returns a tag function that can be used as a template string. It parses the template string into an array of string arguments. Each inserted value is included as a separate argument if it was surrounded by whitespaces.
import {$$} from 'dollar-shell';The TypeScript declaration:
type Backticks<R> = (strings: TemplateStringsArray, ...args: unknown[]) => R;
interface Dollar<R, O = SpawnOptions> extends Backticks<R> {
(options: O): Dollar<R, O>;
}
declare const $$: Dollar<Subprocess>;SpawnOptions and Subprocess are the same as in spawn().
$$ supports two signatures:
const sp1 = $$`ls -l ${myFile}`; // runs a command using the defaults
const sp2 = $$(options)`ls -l .`; // runs a command with custom spawn options
const $tag = $$(options); // returns a tag function
const sp3 = $tag`ls -l .`; // runs a command with custom spawn optionsIn the example above the first use case is a plain tag function that spawns a process using the default spawn options. The second use case is a tag function with custom spawn options. The third use case is a preparing a custom tag function which defaults to some custom spawn options.
This function is effectively a helper for spawn(). It parses the template string
into an array of string arguments. Each inserted value is included
as a separate argument if it was surrounded by whitespaces.
It returns:
- If used as a tag function (the first use case), it returns a sub-process object. See spawn() for more details.
- If used to create a specialized tag function (the second use case), it returns a tag function that can be used as a template string.