diff --git a/src/environment.ts b/src/environment.ts new file mode 100644 index 00000000000..cc90f654375 --- /dev/null +++ b/src/environment.ts @@ -0,0 +1,5 @@ +declare function require(moduleName: string): any + +export const environment = { + VERSION: require('../package.json').version +} diff --git a/src/tillhub-js.ts b/src/tillhub-js.ts index e66c634b0ba..a1b49b02524 100644 --- a/src/tillhub-js.ts +++ b/src/tillhub-js.ts @@ -7,6 +7,7 @@ import * as v0 from './v0' import * as v1 from './v1' import { Client, ClientOptions } from './client' import * as errors from './errors' +import { environment } from './environment' export { v0, v1 } @@ -26,6 +27,7 @@ export class TillhubClient { http?: Client public options: TillhubSDKOptions | undefined + public static environment = environment constructor(options?: TillhubSDKOptions) { // super() diff --git a/test/environment.test.ts b/test/environment.test.ts new file mode 100644 index 00000000000..85e36baed21 --- /dev/null +++ b/test/environment.test.ts @@ -0,0 +1,9 @@ +import { environment } from '../src/environment' + +describe('SDK: environemt', () => { + it('Will have set environment version at compile time', () => { + expect(environment).toBeDefined() + expect(environment.VERSION).toBeDefined() + expect(environment.VERSION).toBe(process.env.npm_package_version) + }) +})