loop-task 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,18 +7,23 @@ function quoteArg(arg) {
|
|
|
7
7
|
return /[\s"]/.test(arg) ? `"${arg.replace(/"/g, '\\"')}"` : arg;
|
|
8
8
|
}
|
|
9
9
|
function formatCommandLine(command, commandArgs) {
|
|
10
|
-
return [command, ...commandArgs.map((a) => quoteArg(a.replace(
|
|
10
|
+
return [command, ...commandArgs.map((a) => quoteArg(a.replace(/[\n\r]/g, " ")))].join(" ").trim();
|
|
11
11
|
}
|
|
12
12
|
export function extractExitCode(error) {
|
|
13
13
|
return error && typeof error === "object" && "exitCode" in error
|
|
14
14
|
? error.exitCode
|
|
15
15
|
: 1;
|
|
16
16
|
}
|
|
17
|
-
export async function executeCommand(command, commandArgs, cwd, logStream, signal, runNumber, captureStdout = false) {
|
|
17
|
+
export async function executeCommand(command, commandArgs, cwd, logStream, signal, runNumber, captureStdout = false, isChain = false) {
|
|
18
18
|
const startedAt = new Date();
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (!isChain) {
|
|
20
|
+
const header = t("loop.runHeader", { timestamp: startedAt.toLocaleString(), runNumber: runNumber ?? 0 });
|
|
21
|
+
logStream.write(header);
|
|
22
|
+
}
|
|
21
23
|
logStream.write(t("loop.commandLine", { command: formatCommandLine(command, commandArgs) }));
|
|
24
|
+
if (cwd) {
|
|
25
|
+
logStream.write(t("loop.cwdLine", { cwd }));
|
|
26
|
+
}
|
|
22
27
|
if (cwd && !fs.existsSync(cwd)) {
|
|
23
28
|
const endedAt = new Date();
|
|
24
29
|
logStream.write(t("loop.cwdMissingLog", { cwd }));
|
|
@@ -33,6 +38,7 @@ export async function executeCommand(command, commandArgs, cwd, logStream, signa
|
|
|
33
38
|
cwd: cwd || undefined,
|
|
34
39
|
cancelSignal: signal,
|
|
35
40
|
shell: true,
|
|
41
|
+
env: process.env,
|
|
36
42
|
});
|
|
37
43
|
const stdoutChunks = [];
|
|
38
44
|
let stdoutTruncated = false;
|
|
@@ -371,7 +371,6 @@ export class LoopController extends EventEmitter {
|
|
|
371
371
|
break;
|
|
372
372
|
if (this.logStream) {
|
|
373
373
|
this.logStream.write(t("loop.chainHeader", { name: chainTask.name, branch: prevBranch, prevExit }));
|
|
374
|
-
this.logStream.write(t("loop.commandLine", { command: [chainTask.command, ...chainTask.commandArgs.map((a) => /[\s"]/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a).map((a) => a.replace(/\n/g, " ").replace(/\r/g, " "))].join(" ").trim() }));
|
|
375
374
|
}
|
|
376
375
|
const chainStartedAt = new Date().toISOString();
|
|
377
376
|
const chainOffset = fs.existsSync(this.logPath) ? fs.statSync(this.logPath).size : 0;
|
|
@@ -388,7 +387,7 @@ export class LoopController extends EventEmitter {
|
|
|
388
387
|
});
|
|
389
388
|
const interpolatedCommand = interpolate(chainTask.command, chainContext);
|
|
390
389
|
const interpolatedArgs = chainTask.commandArgs.map(a => interpolate(a, chainContext));
|
|
391
|
-
const chainResult = await executeCommand(interpolatedCommand, interpolatedArgs, this.options.cwd, this.logStream, signal, this.runCount, true);
|
|
390
|
+
const chainResult = await executeCommand(interpolatedCommand, interpolatedArgs, this.options.cwd, this.logStream, signal, this.runCount, true, true);
|
|
392
391
|
if (chainResult.stdout) {
|
|
393
392
|
const parsed = parseStdout(chainResult.stdout);
|
|
394
393
|
if (parsed !== null) {
|
package/dist/i18n/en.json
CHANGED
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"cli.projectInvalidColor": "Invalid color \"{color}\". Valid names: {valid}, or a #rrggbb hex",
|
|
67
67
|
"loop.runHeader": "\n[Run #{runNumber} - {timestamp}]\n",
|
|
68
68
|
"loop.commandLine": "$ {command}\n",
|
|
69
|
+
"loop.cwdLine": " cwd: {cwd}\n",
|
|
69
70
|
"loop.chainHeader": "\n--- Chain: {name} ({branch}, prev exit {prevExit}) ---\n",
|
|
70
71
|
"loop.exitMarker": "[exit {code} · {duration}]\n",
|
|
71
72
|
"loop.cwdMissingLog": "[error] working directory does not exist: {cwd}\n",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loop-task",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "Loop engineering toolkit. Run any command on a cadence, in the background, managed from a terminal board. Schedule tests, builds, syncs, or agent prompts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|