File tree 2 files changed +9
-31
lines changed
visual-js/visual-snapshots/src
2 files changed +9
-31
lines changed Original file line number Diff line number Diff line change @@ -12,11 +12,6 @@ export interface PdfCommandParams
12
12
concurrency : number ;
13
13
}
14
14
15
- export enum PdfCommandStatus {
16
- SUCCESS ,
17
- FAILURE ,
18
- }
19
-
20
15
export class PdfCommandHandler {
21
16
constructor (
22
17
private readonly visualSnapshotsApi : VisualSnapshotsApi ,
@@ -26,13 +21,12 @@ export class PdfCommandHandler {
26
21
public async handle (
27
22
globsOrDirs : string [ ] ,
28
23
params : PdfCommandParams
29
- ) : Promise < PdfCommandStatus > {
24
+ ) : Promise < void > {
30
25
const pdfFilePaths = await getFiles ( globsOrDirs , "*.pdf" ) ;
31
26
32
27
const buildId =
33
28
params . buildId ?? ( await this . visualSnapshotsApi . createBuild ( params ) ) ;
34
29
35
- let status : PdfCommandStatus ;
36
30
try {
37
31
await this . pdfSnapshotUploader . uploadSnapshots ( {
38
32
buildId,
@@ -41,14 +35,10 @@ export class PdfCommandHandler {
41
35
testNameFormat : params . testName ,
42
36
snapshotNameFormat : params . snapshotName ,
43
37
} ) ;
44
- status = PdfCommandStatus . SUCCESS ;
45
- } catch ( _ ) {
46
- status = PdfCommandStatus . FAILURE ;
47
- }
48
-
49
- if ( ! params . buildId ) {
50
- await this . visualSnapshotsApi . finishBuild ( buildId ) ;
38
+ } finally {
39
+ if ( ! params . buildId ) {
40
+ await this . visualSnapshotsApi . finishBuild ( buildId ) ;
41
+ }
51
42
}
52
- return status ;
53
43
}
54
44
}
Original file line number Diff line number Diff line change @@ -12,11 +12,7 @@ import {
12
12
suiteNameOption ,
13
13
usernameOption ,
14
14
} from "./options.js" ;
15
- import {
16
- PdfCommandHandler ,
17
- PdfCommandParams ,
18
- PdfCommandStatus ,
19
- } from "../app/pdf-handler.js" ;
15
+ import { PdfCommandHandler , PdfCommandParams } from "../app/pdf-handler.js" ;
20
16
import { EOL } from "os" ;
21
17
import { VisualSnapshotsApi } from "../api/visual-snapshots-api.js" ;
22
18
import { initializeVisualApi } from "../api/visual-client.js" ;
@@ -71,19 +67,11 @@ export const pdfCommand = (clientVersion: string) => {
71
67
72
68
new PdfCommandHandler ( visualSnapshotsApi , pdfSnapshotUploader )
73
69
. handle ( globsOrDirs , params )
74
- . then ( ( status : PdfCommandStatus ) => {
75
- if ( status == PdfCommandStatus . SUCCESS ) {
76
- console . info ( "Successfully created PDF snapshots." ) ;
77
- } else {
78
- console . error (
79
- "At least one PDF snapshot creation failed. Please contact Sauce Labs customer support."
80
- ) ;
81
- }
70
+ . then ( ( ) => {
71
+ console . info ( "Successfully created PDF snapshots." ) ;
82
72
} )
83
73
. catch ( ( err ) => {
84
- console . error (
85
- `An unexpected error occured when creating PDF snapshots: ${ err } . Please contact Sauce Labs customer support.`
86
- ) ;
74
+ console . error ( `At least one PDF snapshot creation failed: ${ err } .` ) ;
87
75
} ) ;
88
76
} ) ;
89
77
} ;
You can’t perform that action at this time.
0 commit comments