UNPKG

2.91 kBTypeScriptView Raw
1/// <reference types="node" />
2import { GitProject } from "@atomist/automation-client/lib/project/git/GitProject";
3import { CloneOptions } from "@atomist/automation-client/lib/spi/clone/DirectoryManager";
4import { SpawnSyncOptions } from "child_process";
5import { ExecuteGoalResult } from "../../api/goal/ExecuteGoalResult";
6import { ExecuteGoal, GoalInvocation } from "../../api/goal/GoalInvocation";
7import { ExecPromiseResult, SpawnLogOptions, SpawnLogResult } from "../misc/child_process";
8import { ProjectListenerInvocation } from "./../../api/listener/ProjectListener";
9/**
10 * Convenience access to running child processes in the context of a local project
11 */
12export interface ChildProcessOnProject {
13 /**
14 * Spawn a child process, by default setting cwd to the directory
15 * of the local project and using the progressLog of
16 * GoalInvocation as logger. Any `cwd` passed in the options
17 * overrides the default. See [[spawnLog]] for more details.
18 *
19 * @param cmd Command to spawn
20 * @param args Arguments to command
21 * @param opts Spawn options
22 * @returns Command result
23 */
24 spawn(cmd: string, args?: string | string[], opts?: Partial<SpawnLogOptions>): Promise<SpawnLogResult>;
25 /**
26 * Spawn a child process, by default setting cwd to the directory
27 * of the local project. Any `cwd` passed in the options
28 * overrides the default. See [[execPromise]] for more details.
29 *
30 * @param cmd Command to spawn
31 * @param args Arguments to command
32 * @param opts Spawn options
33 * @returns Command standard output and standard error
34 */
35 exec(cmd: string, args?: string | string[], opts?: SpawnSyncOptions): Promise<ExecPromiseResult>;
36}
37/**
38 * Type providing access to the GoalInvocation, Project and running
39 * child process in the context of the project.
40 */
41export declare type ProjectAwareGoalInvocation = GoalInvocation & ProjectListenerInvocation & ChildProcessOnProject;
42/**
43 * Convenience method to create project aware goal invocations with
44 * spawn and exec functions that, by default, use the cloned project
45 * base directory as the current working directory.
46 *
47 * @param project locally cloned project
48 * @param gi SDM goal invocation
49 * @return goal invocation made project aware
50 */
51export declare function toProjectAwareGoalInvocation(project: GitProject, gi: GoalInvocation): ProjectAwareGoalInvocation;
52/**
53 * Convenience method to create goal implementations that require a local clone of the project.
54 * @param {(pa: ProjectGoalInvocation) => Promise<ExecuteGoalResult>} action
55 * @param {CloneOptions & {readOnly: boolean}} cloneOptions
56 * @returns {ExecuteGoal}
57 */
58export declare function doWithProject(action: (pa: ProjectAwareGoalInvocation) => Promise<void | ExecuteGoalResult>, cloneOptions?: CloneOptions & {
59 readOnly: boolean;
60}): ExecuteGoal;
61//# sourceMappingURL=withProject.d.ts.map
\No newline at end of file