@teamscale/javascript-instrumenter 0.0.1-beta.34 → 0.0.1-beta.35

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.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.0.1-beta.34",
3
+ "version": "0.0.1-beta.35",
4
4
  "description": "Istanbul-based coverage instrumenter with coverage forwarding via WebSockets",
5
5
  "main": "dist/src/main.js",
6
6
  "bin": "dist/src/main.js",
package/dist/src/App.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { TaskResult } from './instrumenter/Task';
2
2
  import { ConfigurationParameters } from './instrumenter/TaskBuilder';
3
- import Logger from "bunyan";
3
+ import Logger from 'bunyan';
4
4
  /**
5
5
  * Entry points of the instrumenter, including command line argument parsing.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,EAAE,uBAAuB,EAAe,MAAM,4BAA4B,CAAC;AAKlF,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;GAEG;AACH,qBAAa,GAAG;IACf;;;OAGG;WACiB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAa9C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAgC1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IA0B1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B;;;;;OAKG;WACW,qBAAqB,CAAC,MAAM,EAAE,uBAAuB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAO1G,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAIxC,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAajC"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtE,OAAO,EAAE,uBAAuB,EAAe,MAAM,4BAA4B,CAAC;AAKlF,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;GAEG;AACH,qBAAa,GAAG;IACf;;;OAGG;WACiB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAa9C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAkC1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IA8B1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAI/B;;;;;OAKG;WACW,qBAAqB,CAAC,MAAM,EAAE,uBAAuB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAO1G,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAIxC,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAajC"}
package/dist/src/App.js CHANGED
@@ -78,10 +78,12 @@ class App {
78
78
  default: 'localhost:54678'
79
79
  });
80
80
  parser.add_argument('-x', '--exclude-origin', {
81
- help: 'Glob pattern of files in the source origin to not produce coverage for.'
81
+ nargs: '*',
82
+ help: 'Glob pattern(s) of files in the source origin to not produce coverage for. Multiple patterns can be separated by space.'
82
83
  });
83
84
  parser.add_argument('-k', '--include-origin', {
84
- help: 'Glob pattern of files in the source origin to produce coverage for.'
85
+ nargs: '*',
86
+ help: 'Glob pattern(s) of files in the source origin to produce coverage for. Multiple patterns can be separated by space.'
85
87
  });
86
88
  parser.add_argument('inputs', { nargs: '+', help: 'The input file(s) to instrument.' });
87
89
  return parser;
@@ -93,7 +95,8 @@ class App {
93
95
  const logfilePath = 'logs/instrumenter.log';
94
96
  mkdirp_1.default.sync(path.dirname(logfilePath));
95
97
  const logLevel = config.debug ? 'debug' : 'error';
96
- return bunyan_1.default.createLogger({ name: "Instrumenter",
98
+ return bunyan_1.default.createLogger({
99
+ name: 'Instrumenter',
97
100
  streams: [
98
101
  {
99
102
  level: logLevel,
@@ -108,13 +111,14 @@ class App {
108
111
  level: logLevel,
109
112
  path: logfilePath
110
113
  }
111
- ] });
114
+ ]
115
+ });
112
116
  }
113
117
  /**
114
118
  * A logger for testing.
115
119
  */
116
120
  static buildDummyLogger() {
117
- return bunyan_1.default.createLogger({ name: "Instrumenter" });
121
+ return bunyan_1.default.createLogger({ name: 'Instrumenter' });
118
122
  }
119
123
  /**
120
124
  * The instrumenter can also be started by providing the configuration dictionary explicitly.
@@ -1 +1 @@
1
- {"version":3,"file":"Cleaner.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Cleaner.ts"],"names":[],"mappings":"AAGA,OAAO,EAKN,cAAc,EACd,MAAM,cAAc,CAAC;AAEtB;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,OAAO,GAClD,MAAM,CAYR"}
1
+ {"version":3,"file":"Cleaner.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Cleaner.ts"],"names":[],"mappings":"AAGA,OAAO,EAKN,cAAc,EAEd,MAAM,cAAc,CAAC;AAEtB;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,OAAO,GAClD,MAAM,CAYR"}
@@ -75,8 +75,7 @@ function extractCoverageCallExpression(expr) {
75
75
  * If this is not the case return `undefined`, and the call expression itself otherwise.
76
76
  */
77
77
  function extractCoverageObjectCall(callExpression) {
78
- if (callExpression && (0, types_1.isIdentifier)(callExpression.callee)
79
- && callExpression.callee.name.startsWith('cov_')) {
78
+ if (callExpression && (0, types_1.isIdentifier)(callExpression.callee) && callExpression.callee.name.startsWith('cov_')) {
80
79
  return callExpression;
81
80
  }
82
81
  return undefined;
@@ -1,5 +1,5 @@
1
1
  import { CollectorSpecifier, InstrumentationTask, OriginSourcePattern, TaskElement, TaskResult } from './Task';
2
- import Logger from "bunyan";
2
+ import Logger from 'bunyan';
3
3
  export declare const IS_INSTRUMENTED_TOKEN = "/** $IS_JS_PROFILER_INSTRUMENTED=true **/";
4
4
  /**
5
5
  * An instrumenter that can conduct a {@code InstrumentationTask}.
@@ -1 +1 @@
1
- {"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EAGnB,WAAW,EACX,UAAU,EACV,MAAM,QAAQ,CAAC;AAUhB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,qBAAqB,8CAA8C,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3D;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACzD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IAEzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAS;gBAEX,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IASnD;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAYhE;;;;;;OAMG;IACG,aAAa,CAClB,SAAS,EAAE,kBAAkB,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,mBAAmB,GAChC,OAAO,CAAC,UAAU,CAAC;YAoGR,6BAA6B;YAkC7B,aAAa;IAe3B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;;;;OAOG;IACH,OAAO,CAAC,gCAAgC;IAQxC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAcpC;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;CAe1B"}
1
+ {"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EAGnB,WAAW,EACX,UAAU,EACV,MAAM,QAAQ,CAAC;AAUhB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,qBAAqB,8CAA8C,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3D;AAED;;GAEG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACzD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IAEzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAS;gBAEX,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IASnD;;OAEG;IACG,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAchE;;;;;;OAMG;IACG,aAAa,CAClB,SAAS,EAAE,kBAAkB,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,mBAAmB,GAChC,OAAO,CAAC,UAAU,CAAC;YA8FR,6BAA6B;YAmC7B,aAAa;IAe3B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;;;;OAOG;IACH,OAAO,CAAC,gCAAgC;IAQxC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAcpC;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;CAe1B"}
@@ -54,9 +54,11 @@ class IstanbulInstrumenter {
54
54
  async instrument(task) {
55
55
  // We limit the number of instrumentations in parallel to one to
56
56
  // not overuse memory (NodeJS has only limited mem to use).
57
- return async_1.default.mapLimit(task.elements, 1, async (taskElement) => {
57
+ return async_1.default
58
+ .mapLimit(task.elements, 1, async (taskElement) => {
58
59
  return await this.instrumentOne(task.collector, taskElement, task.originSourcePattern);
59
- }).then((results) => {
60
+ })
61
+ .then(results => {
60
62
  return results.reduce((prev, curr) => {
61
63
  return prev.withIncrement(curr);
62
64
  }, Task_1.TaskResult.neutral());
@@ -47,7 +47,13 @@ export declare class OriginSourcePattern {
47
47
  * An exclude is stronger than an include.
48
48
  */
49
49
  private readonly exclude;
50
- constructor(include: string | undefined, exclude: string | undefined);
50
+ constructor(include: string[] | undefined, exclude: string[] | undefined);
51
+ /**
52
+ * Normalizes all patterns (normally either include or exclude patterns), and returns all
53
+ * valid normalized patterns. Returns undefined if the patterns list is undefined, or all
54
+ * items inside the list are undefined.
55
+ */
56
+ private normalizePatterns;
51
57
  /**
52
58
  * Does the given pattern require to include the given set of files?
53
59
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAK/C;;GAEG;AACH,8BAAsB,kBAAkB;CAAG;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACvB,sBAAsB;IACtB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC,2BAA2B;IAC3B,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,gEAAgE;IAChE,SAAgB,qBAAqB,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;gBAExD,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB;IAMpF;;OAEG;IACI,SAAS,IAAI,OAAO;CAK3B;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC9B,2CA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D;IACvD,SAAgB,mBAAmB,EAAE,MAAM,CAAC;IAE5C,sDAAsD;IACtD,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,6DAA6D;IAC7D,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,+EAA+E;IAC/E,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAGhC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAC3B,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM;IAkBjB;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAYnD;;OAEG;WACW,OAAO,IAAI,UAAU;IAInC;;;;OAIG;WACW,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU;IAKzC;;;;OAIG;WACW,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;CAI9C;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC7D,2CAA2C;IAC3C,SAAgB,iBAAiB,EAAE,MAAM,CAAC;gBAE9B,iBAAiB,EAAE,MAAM;CAIrC"}
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
@@ -29,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.OriginSourcePattern = exports.CollectorSpecifier = exports.TaskElement = exports.SourceMapReference = void 0;
30
7
  const typescript_optional_1 = require("typescript-optional");
31
8
  const commons_1 = require("@cqse/commons");
32
- const matching = __importStar(require("micromatch"));
9
+ const micromatch_1 = __importDefault(require("micromatch"));
33
10
  const path_1 = __importDefault(require("path"));
34
11
  /**
35
12
  * An abstract source map type.
@@ -78,8 +55,25 @@ exports.CollectorSpecifier = CollectorSpecifier;
78
55
  */
79
56
  class OriginSourcePattern {
80
57
  constructor(include, exclude) {
81
- this.include = OriginSourcePattern.normalizeGlobPattern(include);
82
- this.exclude = OriginSourcePattern.normalizeGlobPattern(exclude);
58
+ this.include = this.normalizePatterns(include);
59
+ this.exclude = this.normalizePatterns(exclude);
60
+ }
61
+ /**
62
+ * Normalizes all patterns (normally either include or exclude patterns), and returns all
63
+ * valid normalized patterns. Returns undefined if the patterns list is undefined, or all
64
+ * items inside the list are undefined.
65
+ */
66
+ normalizePatterns(patterns) {
67
+ if (patterns === undefined || patterns.length === 0) {
68
+ return undefined;
69
+ }
70
+ const normalizedPatterns = patterns
71
+ .map(pattern => OriginSourcePattern.normalizeGlobPattern(pattern))
72
+ .filter(pattern => pattern !== undefined);
73
+ if (patterns.length === 0) {
74
+ return undefined;
75
+ }
76
+ return normalizedPatterns;
83
77
  }
84
78
  /**
85
79
  * Does the given pattern require to include the given set of files?
@@ -94,19 +88,18 @@ class OriginSourcePattern {
94
88
  * or (2) `true` if at least one of the files is supposed to be included.
95
89
  */
96
90
  isAnyIncluded(originFiles) {
97
- var _a;
98
91
  if (originFiles.length === 0) {
99
92
  return true;
100
93
  }
101
94
  const normalizedOriginFiles = originFiles.map(OriginSourcePattern.normalizePath);
102
95
  if (this.exclude) {
103
- const matchedToExclude = matching.match(normalizedOriginFiles, this.exclude);
96
+ const matchedToExclude = (0, micromatch_1.default)(normalizedOriginFiles, this.exclude);
104
97
  if (originFiles.length === matchedToExclude.length) {
105
98
  return false;
106
99
  }
107
100
  }
108
101
  if (this.include) {
109
- const matchedToInclude = matching.match(normalizedOriginFiles, (_a = this.include) !== null && _a !== void 0 ? _a : '**');
102
+ const matchedToInclude = (0, micromatch_1.default)(normalizedOriginFiles, this.include || ['**']);
110
103
  return matchedToInclude.length > 0;
111
104
  }
112
105
  return true;
@@ -7,8 +7,8 @@ export declare type ConfigurationParameters = {
7
7
  to?: string;
8
8
  source_map?: string;
9
9
  collector: string;
10
- include_origin?: string;
11
- exclude_origin?: string;
10
+ include_origin?: string[];
11
+ exclude_origin?: string[];
12
12
  };
13
13
  /**
14
14
  * A builder for an instrumentation task.
@@ -19,16 +19,16 @@ export declare class TaskBuilder {
19
19
  /** The collector to send the coverage to. */
20
20
  private collector;
21
21
  /** An include pattern. */
22
- private originSourceIncludePattern;
22
+ private originSourceIncludePatterns;
23
23
  /** An exclude pattern. */
24
- private originSourceExcludePattern;
24
+ private originSourceExcludePatterns;
25
25
  constructor();
26
26
  /** Set the collector by extracting the information from a given string */
27
27
  setCollectorFromString(collectorSpecification: string): this;
28
- /** Set the include pattern */
29
- setOriginSourceIncludePattern(pattern: string | undefined): this;
30
- /** Set the exclude patter */
31
- setOriginSourceExcludePattern(pattern: string | undefined): this;
28
+ /** Set the include pattern. If multiple patterns are present, concatenates them via the OR operator. */
29
+ setOriginSourceIncludePatterns(patterns: string[] | undefined): this;
30
+ /** Set the exclude pattern(s). If multiple patterns are present, concatenates them via the OR operator. */
31
+ setOriginSourceExcludePatterns(patterns: string[] | undefined): this;
32
32
  /** Add a task element */
33
33
  addElement(fromFilePath: string, toFilePath: string, fromFileSourceMap?: SourceMapReference): this;
34
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"TaskBuilder.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/TaskBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,EAGnB,kBAAkB,EAElB,MAAM,QAAQ,CAAC;AAMhB,2DAA2D;AAC3D,oBAAY,uBAAuB,GAAG;IACrC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAElB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAkBF;;GAEG;AACH,qBAAa,WAAW;IACvB,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAEzC,6CAA6C;IAC7C,OAAO,CAAC,SAAS,CAA4B;IAE7C,0BAA0B;IAC1B,OAAO,CAAC,0BAA0B,CAAqB;IAEvD,0BAA0B;IAC1B,OAAO,CAAC,0BAA0B,CAAqB;;IAOvD,0EAA0E;IAC1E,sBAAsB,CAAC,sBAAsB,EAAE,MAAM,GAAG,IAAI;IAM5D,8BAA8B;IAC9B,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAKhE,6BAA6B;IAC7B,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAKhE,yBAAyB;IACzB,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB,GAAG,IAA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,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAKlG;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI;IAkCpD;;;;;;;OAOG;IACH,OAAO,CAAC,4CAA4C;IAgCpD;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;IASlC;;OAEG;IACI,KAAK,IAAI,mBAAmB;CAInC"}
@@ -58,14 +58,14 @@ class TaskBuilder {
58
58
  this.collector = new Task_1.CollectorSpecifier(collectorSpecification);
59
59
  return this;
60
60
  }
61
- /** Set the include pattern */
62
- setOriginSourceIncludePattern(pattern) {
63
- this.originSourceIncludePattern = pattern;
61
+ /** Set the include pattern. If multiple patterns are present, concatenates them via the OR operator. */
62
+ setOriginSourceIncludePatterns(patterns) {
63
+ this.originSourceIncludePatterns = patterns;
64
64
  return this;
65
65
  }
66
- /** Set the exclude patter */
67
- setOriginSourceExcludePattern(pattern) {
68
- this.originSourceExcludePattern = pattern;
66
+ /** Set the exclude pattern(s). If multiple patterns are present, concatenates them via the OR operator. */
67
+ setOriginSourceExcludePatterns(patterns) {
68
+ this.originSourceExcludePatterns = patterns;
69
69
  return this;
70
70
  }
71
71
  /** Add a task element */
@@ -85,8 +85,8 @@ class TaskBuilder {
85
85
  const target = config.to;
86
86
  const sourceMap = config.source_map;
87
87
  this.setCollectorFromString(config.collector);
88
- this.setOriginSourceIncludePattern(config.include_origin);
89
- this.setOriginSourceExcludePattern(config.exclude_origin);
88
+ this.setOriginSourceIncludePatterns(config.include_origin);
89
+ this.setOriginSourceExcludePatterns(config.exclude_origin);
90
90
  // Handle an explicitly specified source map
91
91
  const sourceMapInfo = loadSourceMap(sourceMap);
92
92
  // Depending on whether or not an in place instrumentation is needed
@@ -163,7 +163,7 @@ class TaskBuilder {
163
163
  * Build the instrumentation task.
164
164
  */
165
165
  build() {
166
- const pattern = new Task_1.OriginSourcePattern(this.originSourceIncludePattern, this.originSourceExcludePattern);
166
+ const pattern = new Task_1.OriginSourcePattern(this.originSourceIncludePatterns, this.originSourceExcludePatterns);
167
167
  return new Task_1.InstrumentationTask(commons_1.Contract.requireDefined(this.collector), this.elements, pattern);
168
168
  }
169
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.0.1-beta.34",
3
+ "version": "0.0.1-beta.35",
4
4
  "description": "Istanbul-based coverage instrumenter with coverage forwarding via WebSockets",
5
5
  "main": "dist/src/main.js",
6
6
  "bin": "dist/src/main.js",