-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathlog.ts
41 lines (32 loc) · 1.06 KB
/
log.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Args } from '@oclif/core';
import { ApifyCommand } from '../../lib/apify_command.js';
import { error, info } from '../../lib/outputs.js';
import { getLoggedClientOrThrow, outputJobLog } from '../../lib/utils.js';
export class BuildLogCommand extends ApifyCommand<typeof BuildLogCommand> {
static override description = 'Prints the log of a specific build.';
static override args = {
buildId: Args.string({
required: true,
description: 'The build ID to get the log from.',
}),
};
async run() {
const { buildId } = this.args;
const apifyClient = await getLoggedClientOrThrow();
const build = await apifyClient.build(buildId).get();
if (!build) {
error({ message: `Build with ID "${buildId}" was not found on your account.`, stdout: true });
return;
}
info({ message: `Log for build with ID "${buildId}":\n` });
try {
await outputJobLog(build);
} catch (err) {
// This should never happen...
error({
message: `Failed to get log for build with ID "${buildId}": ${(err as Error).message}`,
stdout: true,
});
}
}
}