@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.
- package/README.md +28 -12
- package/dist/package.json +17 -15
- package/dist/src/App.d.ts +1 -0
- package/dist/src/App.d.ts.map +1 -0
- package/dist/src/App.js +71 -41
- package/dist/src/instrumenter/FileSystem.d.ts +1 -0
- package/dist/src/instrumenter/FileSystem.d.ts.map +1 -0
- package/dist/src/instrumenter/FileSystem.js +44 -18
- package/dist/src/instrumenter/Instrumenter.d.ts +9 -2
- package/dist/src/instrumenter/Instrumenter.d.ts.map +1 -0
- package/dist/src/instrumenter/Instrumenter.js +99 -47
- package/dist/src/instrumenter/Task.d.ts +3 -2
- package/dist/src/instrumenter/Task.d.ts.map +1 -0
- package/dist/src/instrumenter/Task.js +52 -23
- package/dist/src/instrumenter/TaskBuilder.d.ts +18 -0
- package/dist/src/instrumenter/TaskBuilder.d.ts.map +1 -0
- package/dist/src/instrumenter/TaskBuilder.js +111 -50
- package/dist/src/main.d.ts +1 -0
- package/dist/src/main.d.ts.map +1 -0
- package/dist/src/main.js +4 -2
- package/dist/vaccine.js +216 -571
- package/package.json +13 -15
- package/dist/src/ConfigurationParameters.d.ts +0 -11
- package/dist/src/ConfigurationParameters.js +0 -1
- package/dist/vaccine.js.map +0 -1
package/README.md
CHANGED
|
@@ -17,19 +17,42 @@ information is produced and (2) forwarded to the Collector.
|
|
|
17
17
|
## Building
|
|
18
18
|
|
|
19
19
|
The Instrumenter is written in TypeScript/JavaScript. For building and running it,
|
|
20
|
-
NodeJs (>= v14) and Yarn
|
|
20
|
+
NodeJs (>= v14) and Yarn are needed as prerequisites.
|
|
21
21
|
|
|
22
22
|
```
|
|
23
|
+
yarn clean
|
|
23
24
|
yarn install
|
|
24
25
|
yarn build
|
|
25
26
|
```
|
|
26
27
|
|
|
28
|
+
### Preparation: Source Maps
|
|
29
|
+
|
|
30
|
+
Please make sure to enable the generation of source map files to ensure
|
|
31
|
+
that the profiled code can be mapped back to the original.
|
|
32
|
+
|
|
33
|
+
For example, when the tool Vite is used to bundle the code,
|
|
34
|
+
the generation of source map information can be enabled by setting:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
build: {
|
|
38
|
+
sourcemap: true
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
or
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
build: {
|
|
46
|
+
sourcemap: `inline`
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
27
50
|
## Workflow Integration
|
|
28
51
|
|
|
29
52
|
There are several options to run the Instrumenter. For example, via `yarn` by running
|
|
30
53
|
|
|
31
54
|
```
|
|
32
|
-
yarn
|
|
55
|
+
yarn instrumenter
|
|
33
56
|
```
|
|
34
57
|
|
|
35
58
|
or via `npx` by running
|
|
@@ -51,24 +74,17 @@ the file must contain source-map information, or the source-map file
|
|
|
51
74
|
must be placed along with the source file in the same directory.
|
|
52
75
|
|
|
53
76
|
```
|
|
54
|
-
yarn
|
|
77
|
+
yarn instrument --inplace ./the/path/to/the/file.js
|
|
55
78
|
```
|
|
56
79
|
|
|
57
80
|
```
|
|
58
|
-
yarn
|
|
81
|
+
yarn instrument --inplace ./the/path/to/the/file.js --source-map ./the/path/to/the/source.map
|
|
59
82
|
```
|
|
60
83
|
|
|
61
84
|
```
|
|
62
|
-
yarn
|
|
85
|
+
yarn instrument ./the/path/to/the/file.js --to ./the/file/path/to/write/to.js
|
|
63
86
|
```
|
|
64
87
|
|
|
65
|
-
### Instrumenting all JavaScript Files in a Folder
|
|
66
|
-
|
|
67
|
-
We think that dealing with sets of files, in particular including or excluding
|
|
68
|
-
files that match particular file masks should be done by other tools.
|
|
69
|
-
In a UNIX environment, you should consider using `find` with corresponding
|
|
70
|
-
filters and an `-exec` argument to run the instrumenter.
|
|
71
|
-
|
|
72
88
|
### Integration with Testing Frameworks
|
|
73
89
|
|
|
74
90
|
This is planned work: Provide a Babel plugin that provides a code transformation
|
package/dist/package.json
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamscale/javascript-instrumenter",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-beta.5",
|
|
4
4
|
"description": "Istanbul-based coverage instrumenter with coverage forwarding via WebSockets",
|
|
5
|
-
"main": "dist/main.js",
|
|
6
|
-
"bin": "dist/main.js",
|
|
7
|
-
"types": "dist/main.d.ts",
|
|
5
|
+
"main": "dist/src/main.js",
|
|
6
|
+
"bin": "dist/src/main.js",
|
|
7
|
+
"types": "dist/src/main.d.ts",
|
|
8
8
|
"author": "CQSE GmbH",
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/cqse/teamscale-javascript-profiler.git"
|
|
13
|
+
},
|
|
10
14
|
"scripts": {
|
|
11
15
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
12
|
-
"build": "tsc --project tsconfig.json &&
|
|
13
|
-
"
|
|
14
|
-
"test": "yarn build && jest --forceExit --coverage --silent=true"
|
|
16
|
+
"build": "tsc --project tsconfig.json && node esbuild.mjs",
|
|
17
|
+
"instrumenter": "node dist/src/main.js",
|
|
18
|
+
"test": "yarn build && NODE_OPTIONS='--experimental-vm-modules' jest --forceExit --coverage --silent=true --detectOpenHandles"
|
|
15
19
|
},
|
|
16
20
|
"files": [
|
|
17
21
|
"dist/**/*"
|
|
18
22
|
],
|
|
19
23
|
"devDependencies": {
|
|
20
24
|
"@babel/core": "^7.14.0",
|
|
25
|
+
"@babel/plugin-transform-modules-commonjs": "^7.15.4",
|
|
21
26
|
"@babel/preset-env": "^7.14.1",
|
|
22
|
-
"@rollup/plugin-commonjs": "^20.0.0",
|
|
23
|
-
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
24
|
-
"@rollup/plugin-typescript": "^8.2.5",
|
|
25
27
|
"@types/async": "^3.2.6",
|
|
26
28
|
"@types/convert-source-map": "^1.5.1",
|
|
27
29
|
"@types/glob": "^7.1.3",
|
|
@@ -32,18 +34,17 @@
|
|
|
32
34
|
"@types/source-map": "^0.5.7",
|
|
33
35
|
"@types/ws": "^7.4.4",
|
|
34
36
|
"babel-jest": "^27.2.0",
|
|
37
|
+
"esbuild": "^0.13.3",
|
|
38
|
+
"esbuild-plugin-inline-worker": "^0.1.1",
|
|
35
39
|
"jest": "^27.2.0",
|
|
36
40
|
"rimraf": "^3.0.2",
|
|
37
|
-
"rollup": "^2.56.2",
|
|
38
|
-
"rollup-plugin-auto-named-exports": "^1.0.0-beta.3",
|
|
39
|
-
"rollup-plugin-web-worker-loader": "^1.6.1",
|
|
40
41
|
"ts-jest": "^27.0.5",
|
|
41
42
|
"ts-node": "^10.2.1",
|
|
42
43
|
"tslib": "^2.2.0",
|
|
43
44
|
"typescript": "^4.4.3"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@cqse/commons": "
|
|
47
|
+
"@cqse/commons": "^0.0.1-beta.1",
|
|
47
48
|
"@types/micromatch": "^4.0.2",
|
|
48
49
|
"argparse": "^2.0.1",
|
|
49
50
|
"async": "^3.2.0",
|
|
@@ -57,7 +58,8 @@
|
|
|
57
58
|
"source-map": "0.6.1",
|
|
58
59
|
"typescript-optional": "^2.0.1",
|
|
59
60
|
"unload": "^2.2.0",
|
|
60
|
-
"web-worker": "^1.0.0"
|
|
61
|
+
"web-worker": "^1.0.0",
|
|
62
|
+
"winston": "^3.3.3"
|
|
61
63
|
},
|
|
62
64
|
"publishConfig": {
|
|
63
65
|
"access": "public"
|
package/dist/src/App.d.ts
CHANGED
|
@@ -0,0 +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"}
|
package/dist/src/App.js
CHANGED
|
@@ -1,48 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
9
20
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.App = void 0;
|
|
26
|
+
const argparse_1 = require("argparse");
|
|
27
|
+
const Instrumenter_1 = require("./instrumenter/Instrumenter");
|
|
28
|
+
const commons_1 = require("@cqse/commons");
|
|
29
|
+
const TaskBuilder_1 = require("./instrumenter/TaskBuilder");
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
const package_json_1 = require("../package.json");
|
|
32
|
+
const winston_1 = __importDefault(require("winston"));
|
|
33
|
+
const fs_1 = require("fs");
|
|
17
34
|
/**
|
|
18
35
|
* Entry points of the instrumenter, including command line argument parsing.
|
|
19
36
|
*/
|
|
20
|
-
|
|
37
|
+
class App {
|
|
21
38
|
/**
|
|
22
39
|
* Main function of the instrumenter.
|
|
23
40
|
* Parses the command line options and the instrumentation accordingly.
|
|
24
41
|
*/
|
|
25
|
-
static run() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return this.runForConfigArguments(config, logger);
|
|
35
|
-
});
|
|
42
|
+
static async run() {
|
|
43
|
+
// Parsing of command line arguments:
|
|
44
|
+
// Build the configuration object from the command line arguments.
|
|
45
|
+
const parser = this.buildParser();
|
|
46
|
+
const config = parser.parse_args();
|
|
47
|
+
// Build the logger
|
|
48
|
+
const logger = this.buildLogger(config);
|
|
49
|
+
// Run the instrumenter with the given configuration.
|
|
50
|
+
return this.runForConfigArguments(config, logger);
|
|
36
51
|
}
|
|
37
52
|
/**
|
|
38
53
|
* Build the command line argument parser.
|
|
39
54
|
*/
|
|
40
55
|
static buildParser() {
|
|
41
|
-
const parser = new ArgumentParser({
|
|
56
|
+
const parser = new argparse_1.ArgumentParser({
|
|
42
57
|
description: 'Instrumenter of the Teamscale JavaScript Profiler'
|
|
43
58
|
});
|
|
44
|
-
parser.add_argument('-v', '--version', { action: 'version', version });
|
|
45
|
-
parser.add_argument('-i', '--in-place', {
|
|
59
|
+
parser.add_argument('-v', '--version', { action: 'version', version: package_json_1.version });
|
|
60
|
+
parser.add_argument('-i', '--in-place', {
|
|
61
|
+
action: 'store_true',
|
|
62
|
+
help: 'If set, the original files to instrument are replaced (!!) by their instrumented counterparts.'
|
|
63
|
+
});
|
|
46
64
|
parser.add_argument('-d', '--debug', { action: 'store_true' });
|
|
47
65
|
parser.add_argument('-o', '--to', {
|
|
48
66
|
help: 'Name of the file to write the instrumented version to.'
|
|
@@ -67,14 +85,14 @@ export class App {
|
|
|
67
85
|
* Construct the logger.
|
|
68
86
|
*/
|
|
69
87
|
static buildLogger(config) {
|
|
70
|
-
return
|
|
88
|
+
return winston_1.default.createLogger({
|
|
71
89
|
level: config.debug ? 'debug' : 'info',
|
|
72
|
-
format:
|
|
90
|
+
format: winston_1.default.format.json(),
|
|
73
91
|
defaultMeta: {},
|
|
74
92
|
transports: [
|
|
75
|
-
new
|
|
76
|
-
new
|
|
77
|
-
new
|
|
93
|
+
new winston_1.default.transports.File({ filename: 'logs/instrumenter-error.log', level: 'error' }),
|
|
94
|
+
new winston_1.default.transports.File({ filename: 'logs/instrumenter-combined.log' }),
|
|
95
|
+
new winston_1.default.transports.Console({ format: winston_1.default.format.simple(), level: 'info' })
|
|
78
96
|
]
|
|
79
97
|
});
|
|
80
98
|
}
|
|
@@ -82,11 +100,11 @@ export class App {
|
|
|
82
100
|
* A logger for testing.
|
|
83
101
|
*/
|
|
84
102
|
static buildDummyLogger() {
|
|
85
|
-
return
|
|
103
|
+
return winston_1.default.createLogger({
|
|
86
104
|
level: 'info',
|
|
87
|
-
format:
|
|
105
|
+
format: winston_1.default.format.json(),
|
|
88
106
|
defaultMeta: {},
|
|
89
|
-
transports: [new
|
|
107
|
+
transports: [new winston_1.default.transports.Console({ format: winston_1.default.format.simple(), level: 'info' })]
|
|
90
108
|
});
|
|
91
109
|
}
|
|
92
110
|
/**
|
|
@@ -97,13 +115,25 @@ export class App {
|
|
|
97
115
|
*/
|
|
98
116
|
static runForConfigArguments(config, logger) {
|
|
99
117
|
const task = this.createInstrumentationTask(config);
|
|
100
|
-
Contract.require(task.elements.length > 0, 'The instrumentation task must not be empty.');
|
|
118
|
+
commons_1.Contract.require(task.elements.length > 0, 'The instrumentation task must not be empty.');
|
|
101
119
|
return this.createInstrumenter(logger !== null && logger !== void 0 ? logger : this.buildDummyLogger()).instrument(task);
|
|
102
120
|
}
|
|
103
121
|
static createInstrumentationTask(config) {
|
|
104
|
-
return new TaskBuilder().addFromConfig(config).build();
|
|
122
|
+
return new TaskBuilder_1.TaskBuilder().addFromConfig(config).build();
|
|
105
123
|
}
|
|
106
124
|
static createInstrumenter(logger) {
|
|
107
|
-
|
|
125
|
+
// We have to deal with two different `__dirname` versions,
|
|
126
|
+
// which depends on whether we run from within the IDE or from
|
|
127
|
+
// the command line:
|
|
128
|
+
// dist/src/ OR src/
|
|
129
|
+
const pathVariant1 = path.join(__dirname, '../vaccine.js');
|
|
130
|
+
const pathVariant2 = path.join(__dirname, '../dist/vaccine.js');
|
|
131
|
+
if ((0, fs_1.existsSync)(pathVariant1)) {
|
|
132
|
+
return new Instrumenter_1.IstanbulInstrumenter(pathVariant1, logger);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return new Instrumenter_1.IstanbulInstrumenter(pathVariant2, logger);
|
|
136
|
+
}
|
|
108
137
|
}
|
|
109
138
|
}
|
|
139
|
+
exports.App = App;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/FileSystem.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAU1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAc1D"}
|
|
@@ -1,43 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.expandToFileSet = exports.isDirectoryEmpty = exports.ensureExistingDirectory = exports.isExistingDirectory = exports.isExistingFile = void 0;
|
|
26
|
+
const commons_1 = require("@cqse/commons");
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const mkdirp_1 = __importDefault(require("mkdirp"));
|
|
29
|
+
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const glob_1 = require("glob");
|
|
6
31
|
/**
|
|
7
32
|
* Does the given `path` point to an existing file?
|
|
8
33
|
*/
|
|
9
|
-
|
|
34
|
+
function isExistingFile(path) {
|
|
10
35
|
return fs.existsSync(path) && fs.lstatSync(path).isFile();
|
|
11
36
|
}
|
|
37
|
+
exports.isExistingFile = isExistingFile;
|
|
12
38
|
/**
|
|
13
39
|
* Does the given `path` point to an existing directory?
|
|
14
40
|
*/
|
|
15
|
-
|
|
41
|
+
function isExistingDirectory(path) {
|
|
16
42
|
return fs.existsSync(path) && fs.lstatSync(path).isDirectory();
|
|
17
43
|
}
|
|
44
|
+
exports.isExistingDirectory = isExistingDirectory;
|
|
18
45
|
/**
|
|
19
46
|
* Ensure that the given directory `path` exists.
|
|
20
47
|
*/
|
|
21
|
-
|
|
48
|
+
function ensureExistingDirectory(path) {
|
|
22
49
|
if (!fs.existsSync(path)) {
|
|
23
|
-
|
|
50
|
+
mkdirp_1.default.sync(path);
|
|
24
51
|
}
|
|
25
52
|
if (!fs.lstatSync(path).isDirectory()) {
|
|
26
|
-
throw new InvalidConfigurationException(`The specified path '${path}' does not point to an existing directory!`);
|
|
53
|
+
throw new commons_1.InvalidConfigurationException(`The specified path '${path}' does not point to an existing directory!`);
|
|
27
54
|
}
|
|
28
55
|
}
|
|
56
|
+
exports.ensureExistingDirectory = ensureExistingDirectory;
|
|
29
57
|
/**
|
|
30
58
|
* Is the given directory empty?
|
|
31
59
|
*/
|
|
32
|
-
|
|
60
|
+
function isDirectoryEmpty(path) {
|
|
33
61
|
return !isExistingDirectory(path) || fs.readdirSync(path).length > 0;
|
|
34
62
|
}
|
|
63
|
+
exports.isDirectoryEmpty = isDirectoryEmpty;
|
|
35
64
|
/**
|
|
36
65
|
* Expand a given Glob pattern to a list of files.
|
|
37
66
|
*
|
|
38
67
|
* @param toExpand - The Glob pattern.
|
|
39
68
|
*/
|
|
40
|
-
|
|
69
|
+
function expandToFileSet(toExpand) {
|
|
41
70
|
let globPattern = toExpand;
|
|
42
71
|
if (fs.existsSync(toExpand)) {
|
|
43
72
|
const stat = fs.lstatSync(toExpand, {});
|
|
@@ -45,12 +74,9 @@ export function expandToFileSet(toExpand) {
|
|
|
45
74
|
return [toExpand];
|
|
46
75
|
}
|
|
47
76
|
if (stat.isDirectory()) {
|
|
48
|
-
globPattern = `${toExpand}${
|
|
77
|
+
globPattern = `${toExpand}${path_1.default.sep}**`;
|
|
49
78
|
}
|
|
50
79
|
}
|
|
51
|
-
|
|
52
|
-
if (result.length === 0) {
|
|
53
|
-
throw new InvalidConfigurationException(`No files to instrument found. \n\tWorking directory: '${process.cwd()}'\n\tPattern: '${globPattern}'`);
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
80
|
+
return glob_1.glob.sync(globPattern, { nodir: true });
|
|
56
81
|
}
|
|
82
|
+
exports.expandToFileSet = expandToFileSet;
|
|
@@ -39,13 +39,19 @@ export declare class IstanbulInstrumenter implements IInstrumenter {
|
|
|
39
39
|
* @param sourcePattern - A pattern to restrict the instrumentation to only a fraction of the task element.
|
|
40
40
|
*/
|
|
41
41
|
instrumentOne(collector: CollectorSpecifier, taskElement: TaskElement, sourcePattern: OriginSourcePattern): TaskResult;
|
|
42
|
+
/**
|
|
43
|
+
* Loads the vaccine from the vaccine file and adjusts some template parameters.
|
|
44
|
+
*
|
|
45
|
+
* @param collector - The collector to send coverage information to.
|
|
46
|
+
*/
|
|
47
|
+
private loadVaccine;
|
|
42
48
|
/**
|
|
43
49
|
* Should the given file be excluded from the instrumentation,
|
|
44
50
|
* based on the source files that have been transpiled into it?
|
|
45
51
|
*
|
|
46
52
|
* @param pattern - The pattern to match the origin source files.
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
53
|
+
* @param sourceFile - The bundle file name.
|
|
54
|
+
* @param originSourceFiles - The list of files that were transpiled into the bundle.
|
|
49
55
|
*/
|
|
50
56
|
private shouldExcludeFromInstrumentation;
|
|
51
57
|
/**
|
|
@@ -65,3 +71,4 @@ export declare class IstanbulInstrumenter implements IInstrumenter {
|
|
|
65
71
|
*/
|
|
66
72
|
private loadInputSourceMap;
|
|
67
73
|
}
|
|
74
|
+
//# sourceMappingURL=Instrumenter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/Instrumenter.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EAEnB,WAAW,EACX,UAAU,EACV,MAAM,QAAQ,CAAC;AAOhB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,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;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAW1D;;;;;;OAMG;IACH,aAAa,CACZ,SAAS,EAAE,kBAAkB,EAC7B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,mBAAmB,GAChC,UAAU;IAuFb;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;;;;OAOG;IACH,OAAO,CAAC,gCAAgC;IAQxC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAcpC;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;CAW1B"}
|