@atomist/sdm
Version:
Atomist Software Delivery Machine SDK
61 lines • 2.91 kB
TypeScript
/// <reference types="node" />
import { GitProject } from "@atomist/automation-client/lib/project/git/GitProject";
import { CloneOptions } from "@atomist/automation-client/lib/spi/clone/DirectoryManager";
import { SpawnSyncOptions } from "child_process";
import { ExecuteGoalResult } from "../../api/goal/ExecuteGoalResult";
import { ExecuteGoal, GoalInvocation } from "../../api/goal/GoalInvocation";
import { ExecPromiseResult, SpawnLogOptions, SpawnLogResult } from "../misc/child_process";
import { ProjectListenerInvocation } from "./../../api/listener/ProjectListener";
/**
* Convenience access to running child processes in the context of a local project
*/
export interface ChildProcessOnProject {
/**
* Spawn a child process, by default setting cwd to the directory
* of the local project and using the progressLog of
* GoalInvocation as logger. Any `cwd` passed in the options
* overrides the default. See [[spawnLog]] for more details.
*
* @param cmd Command to spawn
* @param args Arguments to command
* @param opts Spawn options
* @returns Command result
*/
spawn(cmd: string, args?: string | string[], opts?: Partial<SpawnLogOptions>): Promise<SpawnLogResult>;
/**
* Spawn a child process, by default setting cwd to the directory
* of the local project. Any `cwd` passed in the options
* overrides the default. See [[execPromise]] for more details.
*
* @param cmd Command to spawn
* @param args Arguments to command
* @param opts Spawn options
* @returns Command standard output and standard error
*/
exec(cmd: string, args?: string | string[], opts?: SpawnSyncOptions): Promise<ExecPromiseResult>;
}
/**
* Type providing access to the GoalInvocation, Project and running
* child process in the context of the project.
*/
export declare type ProjectAwareGoalInvocation = GoalInvocation & ProjectListenerInvocation & ChildProcessOnProject;
/**
* Convenience method to create project aware goal invocations with
* spawn and exec functions that, by default, use the cloned project
* base directory as the current working directory.
*
* @param project locally cloned project
* @param gi SDM goal invocation
* @return goal invocation made project aware
*/
export declare function toProjectAwareGoalInvocation(project: GitProject, gi: GoalInvocation): ProjectAwareGoalInvocation;
/**
* Convenience method to create goal implementations that require a local clone of the project.
* @param {(pa: ProjectGoalInvocation) => Promise<ExecuteGoalResult>} action
* @param {CloneOptions & {readOnly: boolean}} cloneOptions
* @returns {ExecuteGoal}
*/
export declare function doWithProject(action: (pa: ProjectAwareGoalInvocation) => Promise<void | ExecuteGoalResult>, cloneOptions?: CloneOptions & {
readOnly: boolean;
}): ExecuteGoal;
//# sourceMappingURL=withProject.d.ts.map