@teamscale/javascript-instrumenter 0.0.1-alpha.20 → 0.0.1-beta.5

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.
@@ -1,17 +1,39 @@
1
- import { SourceMapFileReference, TaskResult } from './Task';
2
- import { Contract, IllegalArgumentException } from '@cqse/commons';
3
- import * as istanbul from 'istanbul-lib-instrument';
4
- import * as fs from 'fs';
5
- import * as path from 'path';
6
- import * as convertSourceMap from 'convert-source-map';
7
- export const IS_INSTRUMENTED_TOKEN = '/** $IS_JS_PROFILER_INSTRUMENTED=true **/';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.IstanbulInstrumenter = exports.IS_INSTRUMENTED_TOKEN = void 0;
23
+ const Task_1 = require("./Task");
24
+ const commons_1 = require("@cqse/commons");
25
+ const istanbul = __importStar(require("istanbul-lib-instrument"));
26
+ const fs = __importStar(require("fs"));
27
+ const path = __importStar(require("path"));
28
+ const convertSourceMap = __importStar(require("convert-source-map"));
29
+ exports.IS_INSTRUMENTED_TOKEN = '/** $IS_JS_PROFILER_INSTRUMENTED=true **/';
8
30
  /**
9
31
  * An instrumenter based on the IstanbulJs instrumentation and coverage framework.
10
32
  */
11
- export class IstanbulInstrumenter {
33
+ class IstanbulInstrumenter {
12
34
  constructor(vaccineFilePath, logger) {
13
- this.vaccineFilePath = Contract.requireNonEmpty(vaccineFilePath);
14
- Contract.require(fs.existsSync(vaccineFilePath), `The vaccine file to inject "${vaccineFilePath}" must exist!\nCWD:${process.cwd()}`);
35
+ this.vaccineFilePath = commons_1.Contract.requireNonEmpty(vaccineFilePath);
36
+ commons_1.Contract.require(fs.existsSync(vaccineFilePath), `The vaccine file to inject "${vaccineFilePath}" must exist!\nCWD:${process.cwd()}`);
15
37
  this.logger = logger;
16
38
  }
17
39
  /**
@@ -23,7 +45,7 @@ export class IstanbulInstrumenter {
23
45
  // run several instrumentation workers in parallel?
24
46
  const result = task.elements
25
47
  .map(e => this.instrumentOne(task.collector, e, task.originSourcePattern))
26
- .reduce((prev, current) => current.withIncrement(prev), TaskResult.neutral());
48
+ .reduce((prev, current) => current.withIncrement(prev), Task_1.TaskResult.neutral());
27
49
  return Promise.resolve(result);
28
50
  }
29
51
  /**
@@ -34,20 +56,21 @@ export class IstanbulInstrumenter {
34
56
  * @param sourcePattern - A pattern to restrict the instrumentation to only a fraction of the task element.
35
57
  */
36
58
  instrumentOne(collector, taskElement, sourcePattern) {
59
+ var _a, _b, _c;
37
60
  const inputFileSource = fs.readFileSync(taskElement.fromFile, 'utf8');
38
61
  // We skip files that we have already instrumented
39
- if (inputFileSource.startsWith(IS_INSTRUMENTED_TOKEN)) {
62
+ if (inputFileSource.startsWith(exports.IS_INSTRUMENTED_TOKEN)) {
40
63
  if (!taskElement.isInPlace()) {
41
64
  fs.writeFileSync(taskElement.toFile, inputFileSource);
42
65
  }
43
- return new TaskResult(0, 0, 1, 0, 0, 0);
66
+ return new Task_1.TaskResult(0, 0, 1, 0, 0, 0);
44
67
  }
45
68
  // Not all file types are supported by the instrumenter
46
69
  if (!this.isFileTypeSupported(taskElement.fromFile)) {
47
- return new TaskResult(0, 0, 0, 1, 0, 0);
70
+ return new Task_1.TaskResult(0, 0, 0, 1, 0, 0);
48
71
  }
49
72
  // Report progress
50
- this.logger.info(path.basename(taskElement.fromFile));
73
+ this.logger.info(`Instrumenting "${path.basename(taskElement.fromFile)}"`);
51
74
  let finalSourceMap;
52
75
  let instrumentedSource;
53
76
  // We try to perform the instrumentation with different
@@ -58,24 +81,23 @@ export class IstanbulInstrumenter {
58
81
  try {
59
82
  const instrumenter = istanbul.createInstrumenter(configurationAlternatives[i]);
60
83
  inputSourceMap = this.loadInputSourceMap(inputFileSource, taskElement);
61
- // The main instrumentation (adding coverage statements) is performed now:
62
- instrumentedSource = instrumenter
63
- .instrumentSync(inputFileSource, taskElement.fromFile, inputSourceMap)
64
- .replace(/return actualCoverage/g, 'return makeCoverageInterceptor(actualCoverage)')
65
- .replace(/new Function\("return this"\)\(\)/g, "typeof window === 'object' ? window : this");
66
- this.logger.debug('Instrumentation source maps to:', instrumenter.lastSourceMap().sources);
67
84
  // Based on the source maps of the file to instrument, we can now
68
85
  // decide if we should NOT write an instrumented version of it
69
86
  // and use the original code instead and write it to the target path.
70
87
  //
71
- // TODO: Why is this check not done after `loadInputSourceMap`?
72
- if (this.shouldExcludeFromInstrumentation(sourcePattern, taskElement.fromFile, instrumenter.lastSourceMap().sources)) {
88
+ if (this.shouldExcludeFromInstrumentation(sourcePattern, taskElement.fromFile, (_b = (_a = instrumenter.lastSourceMap()) === null || _a === void 0 ? void 0 : _a.sources) !== null && _b !== void 0 ? _b : [])) {
73
89
  fs.writeFileSync(taskElement.toFile, inputFileSource);
74
- return new TaskResult(1, 0, 0, 0, 0, 0);
90
+ return new Task_1.TaskResult(1, 0, 0, 0, 0, 0);
75
91
  }
92
+ // The main instrumentation (adding coverage statements) is performed now:
93
+ instrumentedSource = instrumenter
94
+ .instrumentSync(inputFileSource, taskElement.fromFile, inputSourceMap)
95
+ .replace(/return actualCoverage/g, 'return makeCoverageInterceptor(actualCoverage)')
96
+ .replace(/new Function\("return this"\)\(\)/g, "typeof window === 'object' ? window : this");
97
+ this.logger.debug('Instrumentation source maps to:', (_c = instrumenter.lastSourceMap()) === null || _c === void 0 ? void 0 : _c.sources);
76
98
  // The process also can result in a new source map that we will append in the result.
77
99
  //
78
- // TODO: Check the actual semantics of `lastSourceMap`
100
+ // `lastSourceMap` === Sourcemap for the last file that was instrumented.
79
101
  finalSourceMap = convertSourceMap.fromObject(instrumenter.lastSourceMap()).toComment();
80
102
  break;
81
103
  }
@@ -84,34 +106,42 @@ export class IstanbulInstrumenter {
84
106
  // we emit a corresponding warning or signal an error.
85
107
  if (i === configurationAlternatives.length - 1) {
86
108
  if (!inputSourceMap) {
87
- return TaskResult.warning(`Failed loading input source map for ${taskElement.fromFile}: ${e.message}`);
109
+ return Task_1.TaskResult.warning(`Failed loading input source map for ${taskElement.fromFile}: ${e.message}`);
88
110
  }
89
111
  fs.writeFileSync(taskElement.toFile, inputFileSource);
90
- return TaskResult.error(e);
112
+ return Task_1.TaskResult.error(e);
91
113
  }
92
114
  }
93
115
  }
94
116
  // We now can glue together the final version of the instrumented file.
95
117
  //
118
+ const vaccineSource = this.loadVaccine(collector);
119
+ fs.writeFileSync(taskElement.toFile, `${exports.IS_INSTRUMENTED_TOKEN} ${vaccineSource} ${instrumentedSource} \n${finalSourceMap}`);
120
+ return new Task_1.TaskResult(1, 0, 0, 0, 0, 0);
121
+ }
122
+ /**
123
+ * Loads the vaccine from the vaccine file and adjusts some template parameters.
124
+ *
125
+ * @param collector - The collector to send coverage information to.
126
+ */
127
+ loadVaccine(collector) {
96
128
  // We first replace some of the parameters in the file with the
97
129
  // actual values, for example, the collector to send the coverage information to.
98
- const vaccineSource = fs
130
+ return fs
99
131
  .readFileSync(this.vaccineFilePath, 'utf8')
100
132
  .replace(/\$REPORT_TO_HOST/g, collector.host)
101
133
  .replace(/\$REPORT_TO_PORT/g, `${collector.port}`);
102
- fs.writeFileSync(taskElement.toFile, `${IS_INSTRUMENTED_TOKEN} ${vaccineSource} ${instrumentedSource} \n${finalSourceMap}`);
103
- return new TaskResult(1, 0, 0, 0, 0, 0);
104
134
  }
105
135
  /**
106
136
  * Should the given file be excluded from the instrumentation,
107
137
  * based on the source files that have been transpiled into it?
108
138
  *
109
139
  * @param pattern - The pattern to match the origin source files.
110
- * @param sourcefile - The bundle file name.
111
- * @param originSourcefiles - The list of files that were transpiled into the bundle.
140
+ * @param sourceFile - The bundle file name.
141
+ * @param originSourceFiles - The list of files that were transpiled into the bundle.
112
142
  */
113
- shouldExcludeFromInstrumentation(pattern, sourcefile, originSourcefiles) {
114
- return !pattern.isAnyIncluded(originSourcefiles);
143
+ shouldExcludeFromInstrumentation(pattern, sourceFile, originSourceFiles) {
144
+ return !pattern.isAnyIncluded(originSourceFiles);
115
145
  }
116
146
  /**
117
147
  * @returns whether the given file is supported for instrumentation.
@@ -131,8 +161,8 @@ export class IstanbulInstrumenter {
131
161
  produceSourceMap: true
132
162
  };
133
163
  return [
134
- Object.assign(Object.assign({}, baseConfig), { esModules: true }),
135
- Object.assign(Object.assign({}, baseConfig), { esModules: false })
164
+ { ...baseConfig, ...{ esModules: true } },
165
+ { ...baseConfig, ...{ esModules: false } }
136
166
  ];
137
167
  }
138
168
  /**
@@ -144,8 +174,8 @@ export class IstanbulInstrumenter {
144
174
  loadInputSourceMap(inputSource, taskElement) {
145
175
  if (taskElement.externalSourceMapFile.isPresent()) {
146
176
  const sourceMapOrigin = taskElement.externalSourceMapFile.get();
147
- if (!(sourceMapOrigin instanceof SourceMapFileReference)) {
148
- throw new IllegalArgumentException('Type of source map not yet supported!');
177
+ if (!(sourceMapOrigin instanceof Task_1.SourceMapFileReference)) {
178
+ throw new commons_1.IllegalArgumentException('Type of source map not yet supported!');
149
179
  }
150
180
  return sourceMapFromMapFile(sourceMapOrigin.sourceMapFilePath);
151
181
  }
@@ -154,6 +184,7 @@ export class IstanbulInstrumenter {
154
184
  }
155
185
  }
156
186
  }
187
+ exports.IstanbulInstrumenter = IstanbulInstrumenter;
157
188
  /**
158
189
  * Extract a sourcemap for a given code comment.
159
190
  *
@@ -165,17 +196,38 @@ function sourceMapFromCodeComment(sourcecode, sourceFilePath) {
165
196
  // or `//# sourceMappingURL=data:application/json;base64,eyJ2ZXJ ...`
166
197
  //
167
198
  // "It is reasonable for tools to also accept “//@” but “//#” is preferred."
168
- const re = /\/\/[#@]\s(source(?:Mapping)?URL)=\s*(\S+)/;
169
- const matched = re.exec(sourcecode);
170
- if (!matched) {
171
- return undefined;
172
- }
173
- const sourceMapComment = matched[0];
174
- if (sourceMapComment.slice(0, 50).indexOf('data:application/json') > 0) {
175
- return convertSourceMap.fromComment(sourceMapComment).toObject();
199
+ const re = /\/\/[#@]\s(source(?:Mapping)?URL)=\s*(\S+)/g;
200
+ let failedLoading = 0;
201
+ let result;
202
+ let matched;
203
+ do {
204
+ matched = re.exec(sourcecode);
205
+ if (matched) {
206
+ const sourceMapComment = matched[0];
207
+ try {
208
+ if (sourceMapComment.slice(0, 50).indexOf('data:application/json') > 0) {
209
+ result = convertSourceMap.fromComment(sourceMapComment).toObject();
210
+ }
211
+ else {
212
+ result = convertSourceMap
213
+ .fromMapFileComment(sourceMapComment, path.dirname(sourceFilePath))
214
+ .toObject();
215
+ }
216
+ }
217
+ catch (e) {
218
+ // One JS file can refer to several source map files in its comments.
219
+ failedLoading++;
220
+ }
221
+ if (result) {
222
+ return result;
223
+ }
224
+ }
225
+ } while (matched);
226
+ if (failedLoading > 0) {
227
+ throw new commons_1.IllegalArgumentException('None of the referenced source map files loaded!');
176
228
  }
177
229
  else {
178
- return convertSourceMap.fromMapFileComment(sourceMapComment, path.dirname(sourceFilePath)).toObject();
230
+ return undefined;
179
231
  }
180
232
  }
181
233
  /**
@@ -40,10 +40,10 @@ export declare class CollectorSpecifier {
40
40
  * are used to determine the original file names.
41
41
  */
42
42
  export declare class OriginSourcePattern {
43
- /** Set of files in the origin for that coverage should be produced. */
43
+ /** Glob pattern describing the set of files in the origin for that coverage should be produced. */
44
44
  private readonly include;
45
45
  /**
46
- * Set of files in the origin for that coverage should EXPLICITLY NOT be produced.
46
+ * Glob pattern describing the set of files in the origin for that coverage should EXPLICITLY NOT be produced.
47
47
  * An exclude is stronger than an include.
48
48
  */
49
49
  private readonly exclude;
@@ -129,3 +129,4 @@ export declare class SourceMapFileReference extends SourceMapReference {
129
129
  readonly sourceMapFilePath: string;
130
130
  constructor(sourceMapFilePath: string);
131
131
  }
132
+ //# sourceMappingURL=Task.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAI/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,2CAA2C;IAC3C,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,gDAAgD;IAChD,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,SAAS,EAAE,MAAM;CAK7B;AAED;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAC/B,mGAAmG;IACnG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAE7C;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEjC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,OAA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uB,SAAQ,kBAAkB;IAC7D,2CAA2C;IAC3C,SAAgB,iBAAiB,EAAE,MAAM,CAAC;gBAE9B,iBAAiB,EAAE,MAAM;CAIrC"}
@@ -1,20 +1,43 @@
1
- import { Optional } from 'typescript-optional';
2
- import { Contract } from '@cqse/commons';
3
- import * as matching from 'micromatch';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.SourceMapFileReference = exports.TaskResult = exports.InstrumentationTask = exports.OriginSourcePattern = exports.CollectorSpecifier = exports.TaskElement = exports.SourceMapReference = void 0;
23
+ const typescript_optional_1 = require("typescript-optional");
24
+ const commons_1 = require("@cqse/commons");
25
+ const matching = __importStar(require("micromatch"));
4
26
  /**
5
27
  * An abstract source map type.
6
28
  */
7
- export class SourceMapReference {
29
+ class SourceMapReference {
8
30
  }
31
+ exports.SourceMapReference = SourceMapReference;
9
32
  /**
10
33
  * One element of an instrumentation task.
11
34
  * It corresponds to instrumenting a single file.
12
35
  */
13
- export class TaskElement {
36
+ class TaskElement {
14
37
  constructor(fromFile, toFile, externalSourceMap) {
15
- this.fromFile = Contract.requireDefined(fromFile);
16
- this.toFile = Contract.requireDefined(toFile);
17
- this.externalSourceMapFile = Optional.ofNullable(externalSourceMap);
38
+ this.fromFile = commons_1.Contract.requireDefined(fromFile);
39
+ this.toFile = commons_1.Contract.requireDefined(toFile);
40
+ this.externalSourceMapFile = typescript_optional_1.Optional.ofNullable(externalSourceMap);
18
41
  }
19
42
  /**
20
43
  * Is it an in-place instrumentation task?
@@ -25,17 +48,19 @@ export class TaskElement {
25
48
  return this.fromFile === this.toFile;
26
49
  }
27
50
  }
51
+ exports.TaskElement = TaskElement;
28
52
  /**
29
53
  * Specifies the collector that is supposed to
30
54
  * receive the coverage information.
31
55
  */
32
- export class CollectorSpecifier {
56
+ class CollectorSpecifier {
33
57
  constructor(collector) {
34
- Contract.requireStringPattern(collector, '.+:[0-9]+', 'Invalid collector pattern used!');
58
+ commons_1.Contract.requireStringPattern(collector, '.+:[0-9]+', 'Invalid collector pattern used!');
35
59
  this.host = collector.split(':')[0];
36
60
  this.port = Number.parseInt(collector.split(':')[1]);
37
61
  }
38
62
  }
63
+ exports.CollectorSpecifier = CollectorSpecifier;
39
64
  /**
40
65
  * Patterns that define which parts of a given bundle to instrument or not.
41
66
  *
@@ -43,7 +68,7 @@ export class CollectorSpecifier {
43
68
  * that is, before conducting all the transpilation steps. The source maps
44
69
  * are used to determine the original file names.
45
70
  */
46
- export class OriginSourcePattern {
71
+ class OriginSourcePattern {
47
72
  constructor(include, exclude) {
48
73
  this.include = include;
49
74
  this.exclude = exclude;
@@ -71,14 +96,15 @@ export class OriginSourcePattern {
71
96
  return true;
72
97
  }
73
98
  }
99
+ exports.OriginSourcePattern = OriginSourcePattern;
74
100
  /**
75
101
  * The actual instrumentation task.
76
102
  */
77
- export class InstrumentationTask {
103
+ class InstrumentationTask {
78
104
  constructor(collector, elements, originSourcePattern) {
79
- this.collector = Contract.requireDefined(collector);
80
- this.originSourcePattern = Contract.requireDefined(originSourcePattern);
81
- this._elements = Contract.requireDefined(elements).slice();
105
+ this.collector = commons_1.Contract.requireDefined(collector);
106
+ this.originSourcePattern = commons_1.Contract.requireDefined(originSourcePattern);
107
+ this._elements = commons_1.Contract.requireDefined(elements).slice();
82
108
  }
83
109
  /**
84
110
  * @returns the elements of the task.
@@ -89,17 +115,18 @@ export class InstrumentationTask {
89
115
  return this._elements.slice();
90
116
  }
91
117
  }
118
+ exports.InstrumentationTask = InstrumentationTask;
92
119
  /**
93
120
  * A summary of executing the instrumentation task.
94
121
  */
95
- export class TaskResult {
122
+ class TaskResult {
96
123
  constructor(translated, translatedFromCache, alreadyInstrumented, unsupported, failed, warnings) {
97
- Contract.require(translated > -1);
98
- Contract.require(translatedFromCache > -1);
99
- Contract.require(alreadyInstrumented > -1);
100
- Contract.require(unsupported > -1);
101
- Contract.require(failed > -1);
102
- Contract.require(warnings > -1);
124
+ commons_1.Contract.require(translated > -1);
125
+ commons_1.Contract.require(translatedFromCache > -1);
126
+ commons_1.Contract.require(alreadyInstrumented > -1);
127
+ commons_1.Contract.require(unsupported > -1);
128
+ commons_1.Contract.require(failed > -1);
129
+ commons_1.Contract.require(warnings > -1);
103
130
  this.translated = translated;
104
131
  this.translatedFromCache = translatedFromCache;
105
132
  this.alreadyInstrumented = alreadyInstrumented;
@@ -140,12 +167,14 @@ export class TaskResult {
140
167
  return new TaskResult(0, 0, 0, 0, 0, 1);
141
168
  }
142
169
  }
170
+ exports.TaskResult = TaskResult;
143
171
  /**
144
172
  * A source map in an external file.
145
173
  */
146
- export class SourceMapFileReference extends SourceMapReference {
174
+ class SourceMapFileReference extends SourceMapReference {
147
175
  constructor(sourceMapFilePath) {
148
176
  super();
149
177
  this.sourceMapFilePath = sourceMapFilePath;
150
178
  }
151
179
  }
180
+ exports.SourceMapFileReference = SourceMapFileReference;
@@ -37,8 +37,26 @@ export declare class TaskBuilder {
37
37
  * @param config - The configuration based on that the task is built.
38
38
  */
39
39
  addFromConfig(config: ConfigurationParameters): this;
40
+ /**
41
+ * Adds instrumentation tasks based on a given pattern `inputs` describing the set of
42
+ * input files and produces the output files in the specified output folder `target.
43
+ *
44
+ * @param inputs - Glob pattern describing set of input files
45
+ * @param target - Target folder
46
+ * @param sourceMapInfo - Source map file for all the input files.
47
+ */
48
+ private addInstrumentationTasksFromPatternWithTarget;
49
+ /**
50
+ * Adds in-place instrumentation tasks for the set of files described
51
+ * by the `inputs` pattern.
52
+ *
53
+ * @param inputs - Glob pattern.
54
+ * @param sourceMapInfo - Source map for the files described by the pattern.
55
+ */
56
+ private addInPlaceTasksFromPattern;
40
57
  /**
41
58
  * Build the instrumentation task.
42
59
  */
43
60
  build(): InstrumentationTask;
44
61
  }
62
+ //# sourceMappingURL=TaskBuilder.d.ts.map
@@ -0,0 +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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