1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.doWithProject = exports.toProjectAwareGoalInvocation = void 0;
|
19 | const string_1 = require("@atomist/automation-client/lib/internal/util/string");
|
20 | const child_process_1 = require("../misc/child_process");
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | function toProjectAwareGoalInvocation(project, gi) {
|
31 | const { progressLog } = gi;
|
32 | const spawn = pagiSpawn(project, progressLog);
|
33 | const exec = pagiExec(project);
|
34 | return Object.assign(Object.assign({}, gi), { project, spawn, exec });
|
35 | }
|
36 | exports.toProjectAwareGoalInvocation = toProjectAwareGoalInvocation;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | function doWithProject(action, cloneOptions = { readOnly: false }) {
|
44 | return gi => {
|
45 | const { context, credentials, id, configuration, progressLog } = gi;
|
46 | return configuration.sdm.projectLoader.doWithProject({
|
47 | context,
|
48 | credentials,
|
49 | id,
|
50 | readOnly: cloneOptions.readOnly,
|
51 | cloneOptions,
|
52 | }, (p) => action(Object.assign(Object.assign({}, gi), { project: p, spawn: pagiSpawn(p, progressLog), exec: pagiExec(p) })));
|
53 | };
|
54 | }
|
55 | exports.doWithProject = doWithProject;
|
56 |
|
57 |
|
58 |
|
59 | function pagiSpawn(p, log) {
|
60 | return (cmd, args = [], opts) => {
|
61 | const optsToUse = Object.assign({ cwd: p.baseDir, log }, opts);
|
62 | return child_process_1.spawnLog(cmd, string_1.toStringArray(args), optsToUse);
|
63 | };
|
64 | }
|
65 |
|
66 |
|
67 |
|
68 | function pagiExec(p) {
|
69 | return (cmd, args = [], opts = {}) => {
|
70 | const optsToUse = Object.assign({ cwd: p.baseDir }, opts);
|
71 | return child_process_1.execPromise(cmd, string_1.toStringArray(args), optsToUse);
|
72 | };
|
73 | }
|
74 |
|
\ | No newline at end of file |