Skip to content

Commit 18ff663

Browse files
add logs only if snapshot is captured for exec
1 parent 33b6be2 commit 18ff663

File tree

7 files changed

+11
-2
lines changed

7 files changed

+11
-2
lines changed

src/commander/capture.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ command
2727
process.exit(1);
2828
}
2929
let ctx: Context = ctxInit(command.optsWithGlobals());
30+
ctx.isSnapshotCaptured = true
3031

3132
if (!fs.existsSync(file)) {
3233
ctx.log.error(`Web Static Config file ${file} not found.`);

src/commander/upload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ command
3434
process.exit(1);
3535
}
3636
let ctx: Context = ctxInit(command.optsWithGlobals());
37+
ctx.isSnapshotCaptured = true
3738

3839
if (!fs.existsSync(directory)) {
3940
console.log(`Error: The provided directory ${directory} not found.`);

src/commander/uploadFigma.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ uploadFigma
2424
.option('--buildName <buildName>', 'Name of the build')
2525
.action(async function (file, _, command) {
2626
let ctx: Context = ctxInit(command.optsWithGlobals());
27+
ctx.isSnapshotCaptured = true;
2728

2829
if (!fs.existsSync(file)) {
2930
console.log(`Error: Figma Config file ${file} not found.`);

src/lib/ctx.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export default (options: Record<string, string>): Context => {
127127
},
128128
cliVersion: version,
129129
totalSnapshots: -1,
130-
isStartExec: false
130+
isStartExec: false,
131+
isSnapshotCaptured: false
131132
}
132133
}

src/lib/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
3838
if (!validateSnapshot(snapshot)) throw new Error(validateSnapshot.errors[0].message);
3939
ctx.testType = testType;
4040
ctx.snapshotQueue?.enqueue(snapshot);
41+
ctx.isSnapshotCaptured = true;
4142
replyCode = 200;
4243
replyBody = { data: { message: "success", warnings: [] }};
4344
} catch (error: any) {

src/tasks/finalizeBuild.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
2929
await ctx.server?.close();
3030
ctx.log.debug(`Closed server`);
3131
let resp = await ctx.client.getS3PreSignedURL(ctx);
32-
await ctx.client.uploadLogs(ctx, resp.data.url);
32+
if (ctx.isSnapshotCaptured) {
33+
ctx.log.debug(`Log file to be uploaded`)
34+
await ctx.client.uploadLogs(ctx, resp.data.url);
35+
}
3336
fs.unlinkSync(constants.LOG_FILE_PATH);
3437
ctx.log.debug(`Log file deleted: ${constants.LOG_FILE_PATH}`);
3538
} catch (error: any) {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface Context {
5353
figmaDesignConfig?: FigmaDesignConfig;
5454
testType?: string;
5555
isStartExec ?: boolean;
56+
isSnapshotCaptured ?: boolean;
5657
}
5758

5859
export interface Env {

0 commit comments

Comments
 (0)