@plugjs/plug
Version:
PlugJS Build System ===================
65 lines (64 loc) • 2.18 kB
TypeScript
import type { ExecChildOptions } from '../utils/exec';
/** Options for executing scripts */
export interface ExecOptions extends ExecChildOptions {
/**
* The current working directory of the process to execute.
*
* Defaults to the current {@link Files.directory | Files' directory}.
*/
cwd?: string;
/**
* Whether the {@link Files} will be appended to the current arguments as
* _relative_ files (default or `true`) or _absolute_ (if `false`).
*/
relativePaths?: boolean;
}
declare module '../index' {
interface Pipe {
/**
* Execute a shell command, adding to its _arguments_ the list of files
* from the current pipe (much like `xargs` does on Unix systems).
*
* For example:
*
* ```
* import { build } from '@plugjs/plugjs'
*
* export default build({
* runme() {
* this.find('*.ts', { directory: 'src' })
* .exec('chmod', '755' })
* .exec('chown root:root', { shell: true })
* },
* })
* ```
*
* @param cmd The command to execute
* @param args Any additional argument for the command to execute
*/
exec(cmd: string, ...args: string[]): Pipe;
/**
* Execute a shell command, adding to its _arguments_ the list of files
* from the current pipe (much like `xargs` does on Unix systems).
*
* For example:
*
* ```
* import { build } from '@plugjs/plugjs'
*
* export default build({
* runme() {
* this.find('*.ts', { directory: 'src' })
* .exec('chmod', '755' })
* .exec('chown root:root', { shell: true })
* },
* })
* ```
*
* @param cmd The command to execute
* @param args Any additional argument for the command to execute
* @param options Extra {@link ExecOptions | options} for process execution
*/
exec(cmd: string, ...extra: [...args: string[], options: ExecOptions]): Pipe;
}
}