Skip to content

Commit 5cea193

Browse files
various fixes
1 parent c1be9cd commit 5cea193

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

src/auth.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ import Credentials from './models/credentials';
55

66
export default class Auth {
77
public static async getCredentials(): Promise<Credentials | null> {
8-
const savedCredentials = (
9-
await fs.promises.readFile(path.join(os.homedir(), '.testingbot'))
10-
).toString();
11-
if (savedCredentials.length > 0) {
12-
const [userName, accessKey] = savedCredentials.split(':');
13-
return new Credentials(userName, accessKey);
8+
try {
9+
const savedCredentials = (
10+
await fs.promises.readFile(path.join(os.homedir(), '.testingbot'))
11+
).toString();
12+
if (savedCredentials.length > 0) {
13+
const [userName, accessKey] = savedCredentials.split(':');
14+
return new Credentials(userName, accessKey);
15+
}
16+
return null;
17+
} catch {
18+
return null;
1419
}
15-
return null;
1620
}
1721
}

src/cli.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ program
4141
}
4242
const espresso = new Espresso(credentials, options);
4343
await espresso.run();
44-
} catch (err: any) {
45-
logger.error(`Espresso error: ${err.message}`);
44+
} catch (err) {
45+
logger.error(
46+
`Espresso error: ${err instanceof Error ? err.message : err}`,
47+
);
4648
}
4749
})
4850
.showHelpAfterError(true);
@@ -68,10 +70,12 @@ program
6870
if (credentials === null) {
6971
throw new Error('Please specify credentials');
7072
}
71-
const maestto = new Maestro(credentials, options);
72-
await maestto.run();
73-
} catch (err: any) {
74-
logger.error(`Maestro error: ${err.message}`);
73+
const maestro = new Maestro(credentials, options);
74+
await maestro.run();
75+
} catch (err) {
76+
logger.error(
77+
`Maestro error: ${err instanceof Error ? err.message : err}`,
78+
);
7579
}
7680
})
7781
.showHelpAfterError(true);
@@ -91,8 +95,10 @@ program
9195
}
9296
const xcuitest = new XCUITest(credentials, options);
9397
await xcuitest.run();
94-
} catch (err: any) {
95-
logger.error(`XCUITest error: ${err.message}`);
98+
} catch (err) {
99+
logger.error(
100+
`XCUITest error: ${err instanceof Error ? err.message : err}`,
101+
);
96102
}
97103
});
98104

src/providers/espresso.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export default class Espresso {
6868

6969
logger.info('Running Espresso Tests');
7070
await this.runTests();
71-
} catch (error: any) {
72-
logger.error(error.message);
71+
} catch (error) {
72+
logger.error(error instanceof Error ? error.message : error);
7373
}
7474
}
7575

@@ -112,7 +112,7 @@ export default class Espresso {
112112
formData,
113113
{
114114
headers: {
115-
'Content-Type': 'application/zip,',
115+
'Content-Type': 'application/zip',
116116
'Content-Disposition': `attachment; filename=${fileName}`,
117117
'User-Agent': utils.getUserAgent(),
118118
},

src/providers/maestro.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export default class Maestro {
6868

6969
logger.info('Running Maestro Tests');
7070
await this.runTests();
71-
} catch (error: any) {
72-
logger.error(error.message);
71+
} catch (error) {
72+
logger.error(error instanceof Error ? error.message : error);
7373
}
7474
}
7575

@@ -112,7 +112,7 @@ export default class Maestro {
112112
formData,
113113
{
114114
headers: {
115-
'Content-Type': 'application/zip,',
115+
'Content-Type': 'application/zip',
116116
'Content-Disposition': `attachment; filename=${fileName}`,
117117
'User-Agent': utils.getUserAgent(),
118118
},

src/providers/xcuitest.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from 'node:path';
66
import FormData from 'form-data';
77
import TestingBotError from '../models/testingbot_error';
88
import XCUITestOptions from '../models/xcuitest_options';
9+
import utils from '../utils';
910

1011
export default class XCUITest {
1112
private readonly URL = 'https://api.testingbot.com/v1/app-automate/xcuitest';
@@ -64,7 +65,7 @@ export default class XCUITest {
6465
logger.info('Running XCUITests');
6566
await this.runTests();
6667
} catch (error) {
67-
logger.error(error);
68+
logger.error(error instanceof Error ? error.message : error);
6869
}
6970
}
7071

@@ -78,6 +79,7 @@ export default class XCUITest {
7879
headers: {
7980
'Content-Type': 'application/octet-stream',
8081
'Content-Disposition': `attachment; filename=${fileName}`,
82+
'User-Agent': utils.getUserAgent(),
8183
},
8284
auth: {
8385
username: this.credentials.userName,
@@ -106,8 +108,9 @@ export default class XCUITest {
106108
formData,
107109
{
108110
headers: {
109-
'Content-Type': 'application/zip,',
111+
'Content-Type': 'application/zip',
110112
'Content-Disposition': `attachment; filename=${fileName}`,
113+
'User-Agent': utils.getUserAgent(),
111114
},
112115
auth: {
113116
username: this.credentials.userName,
@@ -138,6 +141,7 @@ export default class XCUITest {
138141
{
139142
headers: {
140143
'Content-Type': 'application/json',
144+
'User-Agent': utils.getUserAgent(),
141145
},
142146
auth: {
143147
username: this.credentials.userName,

0 commit comments

Comments
 (0)