@teamscale/javascript-instrumenter 0.0.1-beta.28 → 0.0.1-beta.30

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.28",
3
+ "version": "0.0.1-beta.30",
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",
@@ -27,6 +27,7 @@
27
27
  "@babel/plugin-transform-modules-commonjs": "^7.15.4",
28
28
  "@babel/preset-env": "^7.14.1",
29
29
  "@types/async": "^3.2.6",
30
+ "@types/bunyan": "^1.8.8",
30
31
  "@types/convert-source-map": "^1.5.1",
31
32
  "@types/glob": "^7.1.3",
32
33
  "@types/istanbul-lib-instrument": "^1.7.4",
@@ -53,7 +54,8 @@
53
54
  "@cqse/commons": "^0.0.1-beta.1",
54
55
  "@types/micromatch": "^4.0.2",
55
56
  "argparse": "^2.0.1",
56
- "async": "^3.2.0",
57
+ "async": "^3.2.3",
58
+ "bunyan": "^1.8.15",
57
59
  "convert-source-map": "^1.7.0",
58
60
  "foreground-child": "^2.0.0",
59
61
  "glob": "^7.1.7",
@@ -64,8 +66,7 @@
64
66
  "source-map": "0.7.3",
65
67
  "typescript-optional": "^2.0.1",
66
68
  "unload": "^2.2.0",
67
- "web-worker": "^1.0.0",
68
- "winston": "^3.3.3"
69
+ "web-worker": "^1.0.0"
69
70
  },
70
71
  "publishConfig": {
71
72
  "access": "public"
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 'winston';
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;AAGlF,OAAgB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAG1C;;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;IAa1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAS/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;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"}
package/dist/src/App.js CHANGED
@@ -33,8 +33,9 @@ const commons_1 = require("@cqse/commons");
33
33
  const TaskBuilder_1 = require("./instrumenter/TaskBuilder");
34
34
  const path = __importStar(require("path"));
35
35
  const package_json_1 = require("../package.json");
36
- const winston_1 = __importDefault(require("winston"));
37
36
  const fs_1 = require("fs");
37
+ const mkdirp_1 = __importDefault(require("mkdirp"));
38
+ const bunyan_1 = __importDefault(require("bunyan"));
38
39
  /**
39
40
  * Entry points of the instrumenter, including command line argument parsing.
40
41
  */
@@ -89,27 +90,31 @@ class App {
89
90
  * Construct the logger.
90
91
  */
91
92
  static buildLogger(config) {
92
- return winston_1.default.createLogger({
93
- level: config.debug ? 'debug' : 'info',
94
- format: winston_1.default.format.json(),
95
- defaultMeta: {},
96
- transports: [
97
- new winston_1.default.transports.File({ filename: 'logs/instrumenter-error.log', level: 'error' }),
98
- new winston_1.default.transports.File({ filename: 'logs/instrumenter-combined.log' }),
99
- new winston_1.default.transports.Console({ format: winston_1.default.format.simple(), level: 'info' })
100
- ]
101
- });
93
+ const logfilePath = 'logs/instrumenter.log';
94
+ mkdirp_1.default.sync(path.dirname(logfilePath));
95
+ const logLevel = config.debug ? 'debug' : 'error';
96
+ return bunyan_1.default.createLogger({ name: "Instrumenter",
97
+ streams: [
98
+ {
99
+ level: logLevel,
100
+ stream: {
101
+ write: (rec) => {
102
+ console.log('[%s] %s: %s', rec.time.toISOString(), bunyan_1.default.nameFromLevel[rec.level], rec.msg);
103
+ }
104
+ },
105
+ type: 'raw'
106
+ },
107
+ {
108
+ level: logLevel,
109
+ path: logfilePath
110
+ }
111
+ ] });
102
112
  }
103
113
  /**
104
114
  * A logger for testing.
105
115
  */
106
116
  static buildDummyLogger() {
107
- return winston_1.default.createLogger({
108
- level: 'info',
109
- format: winston_1.default.format.json(),
110
- defaultMeta: {},
111
- transports: [new winston_1.default.transports.Console({ format: winston_1.default.format.simple(), level: 'info' })]
112
- });
117
+ return bunyan_1.default.createLogger({ name: "Instrumenter" });
113
118
  }
114
119
  /**
115
120
  * 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,EAON,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,EAON,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,CAcR"}
@@ -18,7 +18,10 @@ function cleanSourceCode(code, esModules, makeCoverable) {
18
18
  const ast = (0, parser_1.parse)(code, { sourceType: esModules ? 'module' : 'script' });
19
19
  (0, traverse_1.default)(ast, {
20
20
  ExpressionStatement(path) {
21
- if (isCoverageIncrementNode(path)) {
21
+ if (isUnsupportedCounterTypeIncrement(path)) {
22
+ path.remove();
23
+ }
24
+ else if (isCoverageIncrementNode(path)) {
22
25
  if (path.node.loc && !makeCoverable(path.node.loc)) {
23
26
  path.remove();
24
27
  }
@@ -36,11 +39,64 @@ function isCoverageIncrementNode(path) {
36
39
  if (!(0, types_1.isUpdateExpression)(expr)) {
37
40
  return false;
38
41
  }
39
- return (expr.operator === '++' &&
42
+ return extractCoverageCallExpression(expr) !== undefined;
43
+ }
44
+ /**
45
+ * Is the given expression statement a coverage increment that
46
+ * is not supported by our approach?
47
+ *
48
+ * For example, branch coverage is not supported.
49
+ */
50
+ function isUnsupportedCounterTypeIncrement(path) {
51
+ if (!(0, types_1.isUpdateExpression)(path.node.expression)) {
52
+ return false;
53
+ }
54
+ return extractBranchCounterExpression(path.node.expression) !== undefined;
55
+ }
56
+ /**
57
+ * Returns the call expression from `cov_2pvvu1hl8v().b[2][0]++;` if
58
+ * the given UpdateExpression is a branch coverage update expression.
59
+ */
60
+ function extractBranchCounterExpression(expr) {
61
+ if (expr.operator === '++' &&
62
+ (0, types_1.isMemberExpression)(expr.argument) &&
63
+ (0, types_1.isMemberExpression)(expr.argument.object) &&
64
+ (0, types_1.isMemberExpression)(expr.argument.object.object) &&
65
+ (0, types_1.isCallExpression)(expr.argument.object.object.object)) {
66
+ // Branch counter
67
+ return extractCoverageObjectCall(expr.argument.object.object.object);
68
+ }
69
+ return undefined;
70
+ }
71
+ /**
72
+ * Returns the call expression from `cov_104fq7oo4i().f[0]++;` if
73
+ * the given UpdateExpression is a function or statement coverage update expression.
74
+ */
75
+ function extractFunctionOrStatementCounterExpression(expr) {
76
+ if (expr.operator === '++' &&
40
77
  (0, types_1.isMemberExpression)(expr.argument) &&
41
78
  (0, types_1.isMemberExpression)(expr.argument.object) &&
42
- (0, types_1.isCallExpression)(expr.argument.object.object) &&
43
- (0, types_1.isIdentifier)(expr.argument.object.object.callee) &&
44
- expr.argument.object.object.callee.name.startsWith('cov_') &&
45
- (0, types_1.isNumericLiteral)(expr.argument.property));
79
+ (0, types_1.isCallExpression)(expr.argument.object.object)) {
80
+ // Function and statement counter
81
+ return extractCoverageObjectCall(expr.argument.object.object);
82
+ }
83
+ return undefined;
84
+ }
85
+ /**
86
+ * Given an `UpdateExpression` extract the call expression returning the coverage object.
87
+ */
88
+ function extractCoverageCallExpression(expr) {
89
+ var _a;
90
+ return (_a = extractBranchCounterExpression(expr)) !== null && _a !== void 0 ? _a : extractFunctionOrStatementCounterExpression(expr);
91
+ }
92
+ /**
93
+ * Check if the given call expression is a coverage call expression.
94
+ * If this is not the case return `undefined`, and the call expression itself otherwise.
95
+ */
96
+ function extractCoverageObjectCall(callExpression) {
97
+ if (callExpression && (0, types_1.isIdentifier)(callExpression.callee)
98
+ && callExpression.callee.name.startsWith('cov_')) {
99
+ return callExpression;
100
+ }
101
+ return undefined;
46
102
  }
@@ -1,5 +1,5 @@
1
1
  import { CollectorSpecifier, InstrumentationTask, OriginSourcePattern, TaskElement, TaskResult } from './Task';
2
- import { Logger } from 'winston';
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;AAOhB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIjC,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;IAehE;;;;;;OAMG;IACG,aAAa,CAClB,SAAS,EAAE,kBAA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;;;OAOG;IACH,OAAO,CAAC,gCAAgC;IAQxC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAcpC;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;CAe1B"}
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.IstanbulInstrumenter = exports.IS_INSTRUMENTED_TOKEN = void 0;
27
30
  const Task_1 = require("./Task");
@@ -29,10 +32,12 @@ const commons_1 = require("@cqse/commons");
29
32
  const source_map_1 = require("source-map");
30
33
  const istanbul = __importStar(require("istanbul-lib-instrument"));
31
34
  const fs = __importStar(require("fs"));
35
+ const mkdirp = __importStar(require("mkdirp"));
32
36
  const path = __importStar(require("path"));
33
37
  const convertSourceMap = __importStar(require("convert-source-map"));
34
38
  const Cleaner_1 = require("./Cleaner");
35
39
  const typescript_optional_1 = require("typescript-optional");
40
+ const async_1 = __importDefault(require("async"));
36
41
  exports.IS_INSTRUMENTED_TOKEN = '/** $IS_JS_PROFILER_INSTRUMENTED=true **/';
37
42
  /**
38
43
  * An instrumenter based on the IstanbulJs instrumentation and coverage framework.
@@ -47,11 +52,15 @@ class IstanbulInstrumenter {
47
52
  * {@inheritDoc #IInstrumenter.instrument}
48
53
  */
49
54
  async instrument(task) {
50
- fs.existsSync(this.vaccineFilePath);
51
- const resolved = await Promise.all(task.elements.map((taskElement) => {
52
- return this.instrumentOne(task.collector, taskElement, task.originSourcePattern);
53
- }));
54
- return resolved.reduce((aggregatedResult, taskResult) => aggregatedResult.withIncrement(taskResult), Task_1.TaskResult.neutral());
55
+ // We limit the number of instrumentations in parallel to one to
56
+ // not overuse memory (NodeJS has only limited mem to use).
57
+ return async_1.default.mapLimit(task.elements, 1, async (taskElement) => {
58
+ return await this.instrumentOne(task.collector, taskElement, task.originSourcePattern);
59
+ }).then((results) => {
60
+ return results.reduce((prev, curr) => {
61
+ return prev.withIncrement(curr);
62
+ }, Task_1.TaskResult.neutral());
63
+ });
55
64
  }
56
65
  /**
57
66
  * Perform the instrumentation for one given task element (file to instrument).
@@ -66,7 +75,7 @@ class IstanbulInstrumenter {
66
75
  // We skip files that we have already instrumented
67
76
  if (inputFileSource.startsWith(exports.IS_INSTRUMENTED_TOKEN)) {
68
77
  if (!taskElement.isInPlace()) {
69
- fs.writeFileSync(taskElement.toFile, inputFileSource);
78
+ writeToFile(taskElement.toFile, inputFileSource);
70
79
  }
71
80
  return new Task_1.TaskResult(0, 0, 0, 1, 0, 0, 0);
72
81
  }
@@ -93,7 +102,7 @@ class IstanbulInstrumenter {
93
102
  //
94
103
  const originSourceFiles = (_a = inputSourceMap === null || inputSourceMap === void 0 ? void 0 : inputSourceMap.sources) !== null && _a !== void 0 ? _a : [];
95
104
  if (this.shouldExcludeFromInstrumentation(sourcePattern, taskElement.fromFile, originSourceFiles)) {
96
- fs.writeFileSync(taskElement.toFile, inputFileSource);
105
+ writeToFile(taskElement.toFile, inputFileSource);
97
106
  return new Task_1.TaskResult(0, 1, 0, 0, 0, 0, 0);
98
107
  }
99
108
  // The main instrumentation (adding coverage statements) is performed now:
@@ -109,7 +118,10 @@ class IstanbulInstrumenter {
109
118
  //
110
119
  // `lastSourceMap` === Sourcemap for the last file that was instrumented.
111
120
  finalSourceMap = convertSourceMap.fromObject(instrumenter.lastSourceMap()).toComment();
112
- break;
121
+ // We now can glue together the final version of the instrumented file.
122
+ const vaccineSource = this.loadVaccine(collector);
123
+ writeToFile(taskElement.toFile, `${exports.IS_INSTRUMENTED_TOKEN} ${vaccineSource} ${instrumentedSource} \n${finalSourceMap}`);
124
+ return new Task_1.TaskResult(1, 0, 0, 0, 0, 0, 0);
113
125
  }
114
126
  catch (e) {
115
127
  // If also the last configuration alternative failed,
@@ -118,16 +130,12 @@ class IstanbulInstrumenter {
118
130
  if (!inputSourceMap) {
119
131
  return Task_1.TaskResult.warning(`Failed loading input source map for ${taskElement.fromFile}: ${e.message}`);
120
132
  }
121
- fs.writeFileSync(taskElement.toFile, inputFileSource);
133
+ writeToFile(taskElement.toFile, inputFileSource);
122
134
  return Task_1.TaskResult.error(e);
123
135
  }
124
136
  }
125
137
  }
126
- // We now can glue together the final version of the instrumented file.
127
- //
128
- const vaccineSource = this.loadVaccine(collector);
129
- fs.writeFileSync(taskElement.toFile, `${exports.IS_INSTRUMENTED_TOKEN} ${vaccineSource} ${instrumentedSource} \n${finalSourceMap}`);
130
- return new Task_1.TaskResult(1, 0, 0, 0, 0, 0, 0);
138
+ return new Task_1.TaskResult(0, 0, 0, 0, 0, 1, 0);
131
139
  }
132
140
  async removeUnwantedInstrumentation(taskElement, instrumentedSource, configurationAlternative, sourcePattern) {
133
141
  // Read the source map from the instrumented file
@@ -137,7 +145,7 @@ class IstanbulInstrumenter {
137
145
  return instrumentedSource;
138
146
  }
139
147
  // Remove the unwanted instrumentation
140
- return (0, Cleaner_1.cleanSourceCode)(instrumentedSource, configurationAlternative.esModules, location => {
148
+ const cleaned = (0, Cleaner_1.cleanSourceCode)(instrumentedSource, configurationAlternative.esModules, location => {
141
149
  const originalPosition = instrumentedSourceMapConsumer.originalPositionFor({
142
150
  line: location.start.line,
143
151
  column: location.start.column
@@ -147,6 +155,9 @@ class IstanbulInstrumenter {
147
155
  }
148
156
  return sourcePattern.isAnyIncluded([originalPosition.source]);
149
157
  });
158
+ // Explicitly free the source map to avoid memory leaks
159
+ instrumentedSourceMapConsumer.destroy();
160
+ return cleaned;
150
161
  }
151
162
  async loadSourceMap(instrumentedSource, instrumentedSourceFileName) {
152
163
  const instrumentedSourceMap = this.loadInputSourceMap(instrumentedSource, instrumentedSourceFileName, typescript_optional_1.Optional.empty());
@@ -276,3 +287,7 @@ function sourceMapFromMapFile(mapFilePath) {
276
287
  const content = fs.readFileSync(mapFilePath, 'utf8');
277
288
  return JSON.parse(content);
278
289
  }
290
+ function writeToFile(filePath, fileContent) {
291
+ mkdirp.sync(path.dirname(filePath));
292
+ fs.writeFileSync(filePath, fileContent);
293
+ }
@@ -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,C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B,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"}
@@ -132,7 +132,11 @@ class TaskBuilder {
132
132
  inputFiles.forEach(f => this.addElement(f, path.join(target, path.basename(f)), sourceMapInfo));
133
133
  }
134
134
  else {
135
- inputFiles.forEach(f => this.addElement(f, path.join(target, path.relative(input, path.basename(f))), sourceMapInfo));
135
+ inputFiles.forEach(f => {
136
+ const pathRelativeToInputDir = path.relative(input, f);
137
+ const targetFileName = path.join(target, pathRelativeToInputDir);
138
+ this.addElement(f, targetFileName, sourceMapInfo);
139
+ });
136
140
  }
137
141
  }
138
142
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamscale/javascript-instrumenter",
3
- "version": "0.0.1-beta.28",
3
+ "version": "0.0.1-beta.30",
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",
@@ -27,6 +27,7 @@
27
27
  "@babel/plugin-transform-modules-commonjs": "^7.15.4",
28
28
  "@babel/preset-env": "^7.14.1",
29
29
  "@types/async": "^3.2.6",
30
+ "@types/bunyan": "^1.8.8",
30
31
  "@types/convert-source-map": "^1.5.1",
31
32
  "@types/glob": "^7.1.3",
32
33
  "@types/istanbul-lib-instrument": "^1.7.4",
@@ -53,7 +54,8 @@
53
54
  "@cqse/commons": "^0.0.1-beta.1",
54
55
  "@types/micromatch": "^4.0.2",
55
56
  "argparse": "^2.0.1",
56
- "async": "^3.2.0",
57
+ "async": "^3.2.3",
58
+ "bunyan": "^1.8.15",
57
59
  "convert-source-map": "^1.7.0",
58
60
  "foreground-child": "^2.0.0",
59
61
  "glob": "^7.1.7",
@@ -64,8 +66,7 @@
64
66
  "source-map": "0.7.3",
65
67
  "typescript-optional": "^2.0.1",
66
68
  "unload": "^2.2.0",
67
- "web-worker": "^1.0.0",
68
- "winston": "^3.3.3"
69
+ "web-worker": "^1.0.0"
69
70
  },
70
71
  "publishConfig": {
71
72
  "access": "public"