varsnap 1.8.5 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * mime-db
3
+ * Copyright(c) 2014 Jonathan Ong
4
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+
8
+ /*!
9
+ * mime-types
10
+ * Copyright(c) 2014 Jonathan Ong
11
+ * Copyright(c) 2015 Douglas Christopher Wilson
12
+ * MIT Licensed
13
+ */
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "varsnap",
3
- "version": "1.8.5",
3
+ "version": "1.9.0",
4
4
  "description": "Varsnap Client",
5
- "main": "dist/built/index.js",
6
- "types": "dist/built/index.d.ts",
5
+ "main": "dist/node.js",
6
+ "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "require": "./dist/built/index.js",
10
- "types": "./dist/built/index.d.ts",
11
- "default": "./dist/built/index.js"
9
+ "browser": {
10
+ "default": "./dist/browser.js"
11
+ },
12
+ "default": {
13
+ "default": "./dist/node.js"
14
+ }
12
15
  },
13
16
  "./gitbranchenv": "./dist/built/varsnap/gitbranchenv.js",
14
17
  "./gitbranchenv.js": "./dist/built/varsnap/gitbranchenv.js"
@@ -19,10 +22,12 @@
19
22
  "cover-node": "nyc ts-mocha test/*",
20
23
  "cover-browser": "mochify --plugin tsify --require ts-node/register --require source-map-support/register --transform [ babelify --ignore [ test ] --plugins [ babel-plugin-istanbul ] ] test/* --allow-chrome-as-root",
21
24
  "cover-report": "nyc report",
22
- "gen-js": "rm -rf built dist/built && tsc && cp -r built dist/built",
23
- "dist": "ts-node bin/browserify.ts | uglifyjs --config-file .uglify.json -o dist/varsnap.js",
24
- "dist-min": "ts-node bin/browserify.ts | uglifyjs --config-file .uglify.min.json -o dist/varsnap.min.js",
25
- "package": "npm run gen-js && npm run dist && npm run dist-min"
25
+ "package": "npm run build:dev && npm run build:prod",
26
+ "build": "webpack --mode=production --node-env=production",
27
+ "build:dev": "webpack --mode=development",
28
+ "build:prod": "webpack --mode=production --node-env=production",
29
+ "watch": "webpack --watch",
30
+ "serve": "webpack serve"
26
31
  },
27
32
  "repository": {
28
33
  "type": "git",
@@ -39,9 +44,7 @@
39
44
  "homepage": "https://github.com/albertyw/varsnap.js#readme",
40
45
  "devDependencies": {
41
46
  "@babel/core": "^7.12.10",
42
- "@babel/preset-env": "^7.12.11",
43
47
  "@istanbuljs/nyc-config-typescript": "^1.0.1",
44
- "@types/browserify": "^12.0.36",
45
48
  "@types/chai": "^4.2.14",
46
49
  "@types/mocha": "^10.0.0",
47
50
  "@types/sinon": "^10.0.4",
@@ -49,7 +52,7 @@
49
52
  "@typescript-eslint/parser": "^5.6.0",
50
53
  "babel-plugin-istanbul": "^6.0.0",
51
54
  "babelify": "^10.0.0",
52
- "browserify": "^17.0.0",
55
+ "bundle-declarations-webpack-plugin": "^4.0.1",
53
56
  "chai": "^4.2.0",
54
57
  "eslint": "^8.4.1",
55
58
  "mocha": "^10.0.0",
@@ -57,17 +60,20 @@
57
60
  "nyc": "^15.1.0",
58
61
  "sinon": "^15.0.0",
59
62
  "source-map-support": "^0.5.19",
60
- "tinyify": "^4.0.0",
63
+ "ts-loader": "^9.3.1",
61
64
  "ts-mocha": "^10.0.0",
62
65
  "ts-node": "^10.1.0",
63
66
  "tsify": "^5.0.2",
64
- "typescript": "^5.0.0",
65
- "uglify-js": "^3.12.3"
67
+ "typescript": "^5.0.4",
68
+ "webpack": "^5.78.0",
69
+ "webpack-cli": "^5.0.1",
70
+ "webpack-dev-server": "^4.11.1"
66
71
  },
67
72
  "dependencies": {
68
73
  "axios": "^0.27.0"
69
74
  },
70
75
  "files": [
76
+ "dist/*",
71
77
  "dist/varsnap.*",
72
78
  "dist/built/index*",
73
79
  "dist/built/varsnap"
@@ -1,3 +0,0 @@
1
- import core = require('./varsnap/core');
2
- declare const _default: typeof core.varsnap;
3
- export = _default;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- const core = require("./varsnap/core");
3
- module.exports = core.varsnap;
@@ -1,100 +0,0 @@
1
- export declare const version = "1.8.5";
2
- export declare const clientName: string;
3
- export interface Config {
4
- varsnap: boolean;
5
- env: string;
6
- branch: string;
7
- producerToken?: string;
8
- consumerToken?: string;
9
- logger?: Logger;
10
- }
11
- type ConfigKeys = keyof Config;
12
- type rawJSONObject = ConsumeSnapResponse | ProduceTrialResponse | TrialGroupRequest | TrialGroupResponse | Record<string, string>;
13
- export interface Logger {
14
- debug(s: string): void;
15
- log(s: string): void;
16
- error(s: string): void;
17
- }
18
- export declare class Util {
19
- static getConfig(config: Config, configKey: ConfigKeys): string;
20
- static setConfig(config: Config, configKey: ConfigKeys, configValue: string | boolean | Logger | undefined): Config;
21
- static getSignature(targetFunc: TargetFunction, funcName: string): string;
22
- static ajax(url: string, requestData: rawJSONObject): Promise<rawJSONObject>;
23
- static debug(config: Config, data: string): void;
24
- static log(config: Config, data: string): void;
25
- static error(config: Config, data: string): void;
26
- static resetProducers(): void;
27
- static resetConsumers(): void;
28
- static getProducers(): Producer[];
29
- static getConsumers(): Consumer[];
30
- static limitString(x: TargetFunctionInput[] | TargetFunctionOutput): string;
31
- static isNode(): boolean;
32
- static getBranch(config: Config): Promise<string>;
33
- }
34
- export declare class Producer {
35
- targetFunc: TargetFunction;
36
- signature: string;
37
- config: Config;
38
- constructor(targetFunc: TargetFunction, signature: string, config: Config);
39
- isEnabled(): boolean;
40
- static serialize(data: TargetFunctionInput[] | TargetFunctionOutput): string;
41
- static serialize_formatted(data: TargetFunctionInput[] | TargetFunctionOutput): string;
42
- produce(args: TargetFunctionInput[], output: TargetFunctionOutput): Promise<boolean>;
43
- }
44
- interface ConsumeSnapResponse {
45
- status: string;
46
- results: Snap[];
47
- }
48
- interface Snap {
49
- id: string;
50
- inputs: string;
51
- prod_outputs: string;
52
- }
53
- interface ProduceTrialResponse {
54
- status: string;
55
- trial_url: string;
56
- }
57
- export declare class Consumer {
58
- targetFunc: TargetFunction;
59
- signature: string;
60
- config: Config;
61
- constructor(targetFunc: TargetFunction, signature: string, config: Config);
62
- isEnabled(): boolean;
63
- static deserialize(data: string): TargetFunctionInput[] | TargetFunctionOutput | undefined;
64
- consume(trialGroup: TrialGroupResponse): Promise<boolean>;
65
- reportCentral(trialGroup: TrialGroupResponse, snap: Snap, prodOutputs: TargetFunctionOutput, localOutputs: TargetFunctionOutput, matches: boolean): Promise<string | boolean>;
66
- reportLog(snapID: string, inputs: TargetFunctionInput[], prodOutputs: TargetFunctionOutput, localOutputs: TargetFunctionOutput, matches: boolean, trialURL: string | boolean): void;
67
- reportTrialGroup(trialGroup: TrialGroupResponse): void;
68
- }
69
- export type TargetFunctionInput = any;
70
- export type TargetFunctionOutput = any;
71
- export interface TargetFunction {
72
- (...args: TargetFunctionInput[]): TargetFunctionOutput;
73
- }
74
- export interface WrappedFunction {
75
- (...args: TargetFunctionInput[]): TargetFunctionOutput;
76
- producer: Producer;
77
- consumer: Consumer;
78
- signature: string;
79
- }
80
- export declare function varsnap(func: TargetFunction, funcName?: string): TargetFunction | WrappedFunction;
81
- export declare namespace varsnap {
82
- var _config: Config;
83
- var updateConfig: (newConfig: Config) => void;
84
- var reset: () => void;
85
- var version: string;
86
- var runTests: typeof import("./core").runTests;
87
- }
88
- interface TrialGroupRequest {
89
- branch: string;
90
- consumer_token: string;
91
- client: string;
92
- }
93
- interface TrialGroupResponse {
94
- status: string;
95
- project_id: string;
96
- trial_group_id: string;
97
- trial_group_url: string;
98
- }
99
- export declare function runTests(): Promise<boolean>;
100
- export {};
@@ -1,443 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runTests = exports.varsnap = exports.Consumer = exports.Producer = exports.Util = exports.clientName = exports.version = void 0;
4
- const axios_1 = require("axios");
5
- const child_process_1 = require("child_process");
6
- const produceURL = 'https://www.varsnap.com/api/snap/produce/';
7
- const consumeURL = 'https://www.varsnap.com/api/snap/consume/';
8
- const produceTrialURL = 'https://www.varsnap.com/api/trial/produce/';
9
- const trialGroupURL = 'https://www.varsnap.com/api/trial_group/';
10
- exports.version = '1.8.5';
11
- exports.clientName = 'javascript.' + exports.version;
12
- const defaultConfig = {
13
- varsnap: true,
14
- env: 'development',
15
- branch: '',
16
- producerToken: '',
17
- consumerToken: '',
18
- logger: console, // eslint-disable-line no-console
19
- };
20
- let Producers = [];
21
- let Consumers = [];
22
- class Util {
23
- static getConfig(config, configKey) {
24
- if (!config) {
25
- return '';
26
- }
27
- let val = config[configKey];
28
- if (!val) {
29
- return '';
30
- }
31
- val = val.toString().toLowerCase();
32
- return val;
33
- }
34
- static setConfig(config, configKey, configValue) {
35
- if (configKey === 'varsnap') {
36
- if (typeof configValue === 'string') {
37
- configValue = configValue === 'true';
38
- }
39
- config[configKey] = configValue;
40
- }
41
- if (configKey === 'env' || configKey === 'producerToken' || configKey === 'consumerToken' || configKey === 'branch') {
42
- config[configKey] = configValue;
43
- }
44
- if (configKey === 'logger') {
45
- config[configKey] = configValue;
46
- }
47
- return config;
48
- }
49
- static getSignature(targetFunc, funcName) {
50
- let signature = '';
51
- if (funcName !== '' && funcName !== undefined) {
52
- signature = funcName;
53
- }
54
- else {
55
- // Remove any implementation code from signature
56
- signature = targetFunc.toString().split('{')[0];
57
- // Trim preceding and trailing whitespace
58
- signature = signature.replace(/^\s+|\s+$/g, '');
59
- // Trim whitespace between comma separated arguments
60
- signature = signature.replace(/,\s+/g, ',');
61
- }
62
- return 'javascript.' + exports.version + '.' + signature;
63
- }
64
- static ajax(url, requestData) {
65
- const requestParams = new URLSearchParams(requestData);
66
- const data = requestParams.toString();
67
- const options = {
68
- method: 'POST',
69
- url: url,
70
- headers: {
71
- 'Content-Type': 'application/x-www-form-urlencoded',
72
- },
73
- data: data,
74
- responseType: 'json',
75
- };
76
- if (Util.isNode() && options.headers) {
77
- options.headers['User-Agent'] = 'varsnap.js';
78
- }
79
- const ajaxPromise = (0, axios_1.default)(options).then((response) => {
80
- return response.data;
81
- }).catch((error) => {
82
- return error;
83
- });
84
- return ajaxPromise;
85
- }
86
- static debug(config, data) {
87
- if (config.logger) {
88
- config.logger.debug(data);
89
- }
90
- }
91
- static log(config, data) {
92
- if (config.logger) {
93
- config.logger.log(data);
94
- }
95
- }
96
- static error(config, data) {
97
- if (config.logger) {
98
- config.logger.error(data);
99
- }
100
- }
101
- static resetProducers() {
102
- Producers = [];
103
- }
104
- static resetConsumers() {
105
- Consumers = [];
106
- }
107
- static getProducers() {
108
- return Producers;
109
- }
110
- static getConsumers() {
111
- return Consumers;
112
- }
113
- static limitString(x) {
114
- const limitedString = String(x);
115
- const limit = 30;
116
- const ellipsis = '...';
117
- if (limitedString.length <= limit) {
118
- return limitedString;
119
- }
120
- return limitedString.substring(0, 30 - ellipsis.length) + ellipsis;
121
- }
122
- static isNode() {
123
- if (typeof process !== 'object') {
124
- return false;
125
- }
126
- if (typeof window !== 'undefined') {
127
- return false;
128
- }
129
- return true;
130
- }
131
- static getBranch(config) {
132
- const configBranch = Util.getConfig(config, 'branch');
133
- if (configBranch) {
134
- const configPromise = new Promise((resolve) => {
135
- return resolve(configBranch);
136
- });
137
- return configPromise;
138
- }
139
- if (!Util.isNode()) {
140
- const defaultPromise = new Promise((resolve) => {
141
- return resolve('');
142
- });
143
- return defaultPromise;
144
- }
145
- const command = 'git rev-parse --abbrev-ref HEAD';
146
- return new Promise((resolve) => {
147
- (0, child_process_1.exec)(command, (err, stdout) => {
148
- return resolve(stdout.trim());
149
- });
150
- });
151
- }
152
- }
153
- exports.Util = Util;
154
- class Producer {
155
- constructor(targetFunc, signature, config) {
156
- this.targetFunc = targetFunc;
157
- this.signature = signature;
158
- this.config = config;
159
- }
160
- isEnabled() {
161
- if (!this.config.varsnap) {
162
- return false;
163
- }
164
- if (Util.getConfig(this.config, 'env') !== 'production') {
165
- return false;
166
- }
167
- if (!Util.getConfig(this.config, 'producerToken')) {
168
- return false;
169
- }
170
- return true;
171
- }
172
- static serialize(data) {
173
- return JSON.stringify(data);
174
- }
175
- static serialize_formatted(data) {
176
- return JSON.stringify(data, null, 2);
177
- }
178
- produce(args, output) {
179
- if (!this.isEnabled()) {
180
- const errorPromise = new Promise((resolve) => {
181
- return resolve(false);
182
- });
183
- return errorPromise;
184
- }
185
- Util.debug(this.config, 'Sending call to Varsnap');
186
- return Promise.resolve(output).then((outputValue) => {
187
- const data = {
188
- 'producer_token': Util.getConfig(this.config, 'producerToken'),
189
- 'signature': this.signature,
190
- 'inputs': Producer.serialize(args),
191
- 'prod_outputs': Producer.serialize(outputValue),
192
- };
193
- return Util.ajax(produceURL, data).then(() => {
194
- return true;
195
- }).catch((err) => {
196
- if (err.response) {
197
- if (err.response.status === 429) {
198
- Util.error(this.config, 'Cannot produce to Varsnap; Signature at rate limit');
199
- return true;
200
- }
201
- if (err.response.status === 404) {
202
- Util.error(this.config, 'Cannot produce to Varsnap; check your producer token');
203
- }
204
- else {
205
- Util.error(this.config, err.response.statusText);
206
- }
207
- }
208
- return false;
209
- });
210
- });
211
- }
212
- }
213
- exports.Producer = Producer;
214
- class Consumer {
215
- constructor(targetFunc, signature, config) {
216
- this.targetFunc = targetFunc;
217
- this.signature = signature;
218
- this.config = config;
219
- }
220
- isEnabled() {
221
- if (!this.config.varsnap) {
222
- return false;
223
- }
224
- if (Util.getConfig(this.config, 'env') !== 'development') {
225
- return false;
226
- }
227
- if (!Util.getConfig(this.config, 'consumerToken')) {
228
- return false;
229
- }
230
- return true;
231
- }
232
- static deserialize(data) {
233
- if (data === '') {
234
- return undefined;
235
- }
236
- return JSON.parse(data);
237
- }
238
- consume(trialGroup) {
239
- if (!this.isEnabled()) {
240
- const errorPromise = new Promise((resolve) => {
241
- Util.error(this.config, 'Varsnap not enabled for testing');
242
- return resolve(false);
243
- });
244
- return errorPromise;
245
- }
246
- const data = {
247
- 'consumer_token': Util.getConfig(this.config, 'consumerToken'),
248
- 'signature': this.signature,
249
- };
250
- const ajax = Util.ajax(consumeURL, data);
251
- const consume = ajax.then((rawResponse) => {
252
- const response = rawResponse;
253
- if (!response || response.status !== 'ok') {
254
- const errorPromise = new Promise((resolve) => {
255
- Util.error(this.config, 'Received error from Varsnap: ' + response.status);
256
- return resolve(false);
257
- });
258
- return [errorPromise];
259
- }
260
- if (response.results.length === 0) {
261
- Util.log(this.config, 'No snaps found for signature: ' + data.signature);
262
- }
263
- const trialPromises = [];
264
- for (const snap of response.results) {
265
- const inputs = Consumer.deserialize(snap['inputs']);
266
- const prodOutputs = Consumer.deserialize(snap['prod_outputs']);
267
- let localOutputs;
268
- try {
269
- localOutputs = this.targetFunc(...inputs);
270
- }
271
- catch (err) {
272
- localOutputs = err;
273
- }
274
- const trialPromise = Promise.resolve(localOutputs).then((localOutputValue) => {
275
- const prodOutputsSerialized = Producer.serialize(prodOutputs);
276
- const localOutputsSerialized = Producer.serialize(localOutputValue);
277
- const matches = prodOutputsSerialized === localOutputsSerialized;
278
- this.reportCentral(trialGroup, snap, prodOutputs, localOutputValue, matches).then((trialURL) => {
279
- this.reportLog(snap['id'], inputs, prodOutputs, localOutputValue, matches, trialURL);
280
- });
281
- return matches;
282
- });
283
- trialPromises.push(trialPromise);
284
- }
285
- return trialPromises;
286
- }).then((trialPromises) => {
287
- return Promise.all(trialPromises).then((results) => {
288
- const allMatches = results.every((result) => result);
289
- return allMatches;
290
- });
291
- }).catch((error) => {
292
- Util.error(this.config, 'Cannot contact Varsnap: ' + error);
293
- return false;
294
- });
295
- return consume;
296
- }
297
- reportCentral(trialGroup, snap, prodOutputs, localOutputs, matches) {
298
- const data = {
299
- 'trial_group_id': trialGroup.trial_group_id,
300
- 'consumer_token': Util.getConfig(this.config, 'consumerToken'),
301
- 'snap_id': snap.id,
302
- 'test_outputs': Producer.serialize(localOutputs),
303
- 'matches': matches.toString(),
304
- 'snap_outputs_formatted': Producer.serialize_formatted(prodOutputs),
305
- 'test_outputs_formatted': Producer.serialize_formatted(localOutputs),
306
- };
307
- const ajax = Util.ajax(produceTrialURL, data);
308
- const report = ajax.then((rawResponse) => {
309
- const response = rawResponse;
310
- if (!response || response.status !== 'ok') {
311
- return false;
312
- }
313
- const trialURL = response['trial_url'];
314
- return trialURL;
315
- }).catch((error) => {
316
- Util.error(this.config, 'Cannot upload test results to Varsnap: ' + error);
317
- return false;
318
- });
319
- return report;
320
- }
321
- reportLog(snapID, inputs, prodOutputs, localOutputs, matches, trialURL) {
322
- if (matches) {
323
- return;
324
- }
325
- Util.log(this.config, '');
326
- Util.log(this.config, 'Testing with Varsnap uuid: ' + snapID);
327
- Util.log(this.config, 'Signature: ' + this.signature);
328
- Util.log(this.config, 'Function input args: ' + Util.limitString(inputs));
329
- Util.log(this.config, 'Production function outputs: ' + Util.limitString(prodOutputs));
330
- Util.log(this.config, 'Your function outputs: ' + Util.limitString(localOutputs));
331
- Util.log(this.config, 'Matching outputs: ' + matches);
332
- let trialURLView = 'Cannot upload trial';
333
- if (trialURL) {
334
- trialURLView = String(trialURL);
335
- }
336
- Util.log(this.config, 'Trial URL: ' + trialURLView);
337
- }
338
- reportTrialGroup(trialGroup) {
339
- Util.log(this.config, 'Trial Group: ' + trialGroup.trial_group_url);
340
- }
341
- }
342
- exports.Consumer = Consumer;
343
- function varsnap(func, funcName) {
344
- if (funcName === undefined) {
345
- funcName = '';
346
- }
347
- const signature = Util.getSignature(func, funcName);
348
- const producer = new Producer(func, signature, varsnap._config);
349
- const consumer = new Consumer(func, signature, varsnap._config);
350
- const wrapped = function (...args) {
351
- let result;
352
- try {
353
- result = func(...args);
354
- }
355
- catch (err) {
356
- producer.produce(args, err);
357
- throw (err);
358
- }
359
- producer.produce(args, result);
360
- return result;
361
- };
362
- wrapped.producer = producer;
363
- wrapped.consumer = consumer;
364
- wrapped.signature = signature;
365
- Producers.push(producer);
366
- Consumers.push(consumer);
367
- return wrapped;
368
- }
369
- exports.varsnap = varsnap;
370
- varsnap._config = defaultConfig;
371
- varsnap.updateConfig = function updateConfig(newConfig) {
372
- let config = varsnap._config;
373
- for (const key of Object.keys(varsnap._config)) {
374
- if (Object.prototype.hasOwnProperty.call(newConfig, key)) {
375
- config = Util.setConfig(config, key, newConfig[key]);
376
- }
377
- }
378
- varsnap._config = config;
379
- };
380
- varsnap.reset = function reset() {
381
- Util.resetConsumers();
382
- Util.resetProducers();
383
- };
384
- varsnap.version = exports.version;
385
- function getTrialGroup(consumerConfig) {
386
- const getBranch = Util.getBranch(consumerConfig);
387
- const getRequestConfig = getBranch.then((branch) => {
388
- const data = {
389
- 'branch': branch,
390
- 'consumer_token': Util.getConfig(consumerConfig, 'consumerToken'),
391
- 'client': exports.clientName,
392
- };
393
- return data;
394
- });
395
- const ajax = getRequestConfig.then((data) => {
396
- const raw = data;
397
- return Util.ajax(trialGroupURL, raw);
398
- });
399
- const trialGroup = ajax.then((rawResponse) => {
400
- const response = rawResponse;
401
- return response;
402
- }).catch((error) => {
403
- let errorMessage = '';
404
- if (error && error.response && error.response.data) {
405
- const response = error.response.data;
406
- errorMessage = response.error;
407
- }
408
- else {
409
- errorMessage = error.toString();
410
- }
411
- Util.error(consumerConfig, 'Cannot generate a new Trial Group: ' + errorMessage);
412
- return {
413
- status: 'not ok',
414
- project_id: '',
415
- trial_group_id: '',
416
- trial_group_url: '',
417
- };
418
- });
419
- return trialGroup;
420
- }
421
- function runTests() {
422
- const consumers = Util.getConsumers();
423
- if (consumers.length === 0) {
424
- return Promise.resolve(true);
425
- }
426
- const consumerConfig = consumers[0].config;
427
- return getTrialGroup(consumerConfig).then((trialGroup) => {
428
- const testPromises = [];
429
- for (const consumer of consumers) {
430
- const testPromise = consumer.consume(trialGroup);
431
- testPromises.push(testPromise);
432
- }
433
- if (consumers.length > 0) {
434
- consumers[0].reportTrialGroup(trialGroup);
435
- }
436
- return Promise.all(testPromises);
437
- }).then((results) => {
438
- const allPass = results.every((result) => result);
439
- return allPass;
440
- });
441
- }
442
- exports.runTests = runTests;
443
- varsnap.runTests = runTests;
@@ -1 +0,0 @@
1
- export declare function setGitBranchEnv(): Promise<string>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setGitBranchEnv = void 0;
4
- const core_1 = require("./core");
5
- /* Read git branch information from git and save it into an environment variable
6
- * Useful when combined with envify (or loose-envify) when packaging browser apps
7
- */
8
- function setGitBranchEnv() {
9
- const config = {
10
- varsnap: true,
11
- env: 'none',
12
- branch: '',
13
- };
14
- return core_1.Util.getBranch(config)
15
- .then((branch) => {
16
- process.env.GIT_BRANCH = branch;
17
- return branch;
18
- });
19
- }
20
- exports.setGitBranchEnv = setGitBranchEnv;
21
- setGitBranchEnv();