generated from getsentry/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathcli.ts
33 lines (29 loc) · 824 Bytes
/
cli.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
import {getTraceData} from '@sentry/node';
import SentryCli, {SentryCliReleases} from '@sentry/cli';
// @ts-ignore
import {version} from '../package.json';
/**
* CLI Singleton
*
* When the `MOCK` environment variable is set, stub out network calls.
*/
export const getCLI = (): SentryCliReleases => {
// Set the User-Agent string.
process.env['SENTRY_PIPELINE'] = `github-action-release/${version}`;
const cli = new SentryCli(null, {
headers: {
// Propagate sentry trace if we have one
...getTraceData(),
},
}).releases;
if (process.env['MOCK']) {
cli.execute = async (
args: string[],
// eslint-disable-next-line @typescript-eslint/no-unused-vars
live: boolean
): Promise<string> => {
return Promise.resolve(args.join(' '));
};
}
return cli;
};