nyc 11.8.0 → 11.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.
- package/CHANGELOG.md +10 -0
- package/index.js +14 -10
- package/lib/commands/instrument.js +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="11.9.0"></a>
|
|
6
|
+
# [11.9.0](https://github.com/istanbuljs/nyc/compare/v11.8.0...v11.9.0) (2018-05-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add option that allows instrument to exit on error ([#850](https://github.com/istanbuljs/nyc/issues/850)) ([1329a3b](https://github.com/istanbuljs/nyc/commit/1329a3b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
5
15
|
<a name="11.8.0"></a>
|
|
6
16
|
# [11.8.0](https://github.com/istanbuljs/nyc/compare/v11.7.3...v11.8.0) (2018-05-14)
|
|
7
17
|
|
package/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
/* global __coverage__ */
|
|
2
4
|
|
|
3
5
|
const arrify = require('arrify')
|
|
@@ -268,25 +270,27 @@ NYC.prototype._maybeInstrumentSource = function (code, filename, relFile) {
|
|
|
268
270
|
}
|
|
269
271
|
|
|
270
272
|
NYC.prototype._transformFactory = function (cacheDir) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
var instrumented
|
|
273
|
+
const instrumenter = this.instrumenter()
|
|
274
|
+
let instrumented
|
|
274
275
|
|
|
275
|
-
return
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
return (code, metadata, hash) => {
|
|
277
|
+
const filename = metadata.filename
|
|
278
|
+
let sourceMap = null
|
|
278
279
|
|
|
279
|
-
if (
|
|
280
|
+
if (this._sourceMap) sourceMap = this.sourceMaps.extractAndRegister(code, filename, hash)
|
|
280
281
|
|
|
281
282
|
try {
|
|
282
283
|
instrumented = instrumenter.instrumentSync(code, filename, sourceMap)
|
|
283
284
|
} catch (e) {
|
|
284
|
-
// don't fail external tests due to instrumentation bugs.
|
|
285
285
|
debugLog('failed to instrument ' + filename + 'with error: ' + e.stack)
|
|
286
|
-
|
|
286
|
+
if (this.config.exitOnError) {
|
|
287
|
+
process.exit(1)
|
|
288
|
+
} else {
|
|
289
|
+
instrumented = code
|
|
290
|
+
}
|
|
287
291
|
}
|
|
288
292
|
|
|
289
|
-
if (
|
|
293
|
+
if (this.fakeRequire) {
|
|
290
294
|
return 'function x () {}'
|
|
291
295
|
} else {
|
|
292
296
|
return instrumented
|
|
@@ -46,6 +46,11 @@ exports.builder = function (yargs) {
|
|
|
46
46
|
type: 'boolean',
|
|
47
47
|
description: 'should nyc handle instrumentation?'
|
|
48
48
|
})
|
|
49
|
+
.option('exit-on-error', {
|
|
50
|
+
default: false,
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
description: 'should nyc exit when an instrumentation failure occurs?'
|
|
53
|
+
})
|
|
49
54
|
.example('$0 instrument ./lib ./output', 'instrument all .js files in ./lib with coverage and output in ./output')
|
|
50
55
|
}
|
|
51
56
|
|
|
@@ -62,7 +67,8 @@ exports.handler = function (argv) {
|
|
|
62
67
|
extension: argv.extension,
|
|
63
68
|
require: argv.require,
|
|
64
69
|
compact: argv.compact,
|
|
65
|
-
preserveComments: argv.preserveComments
|
|
70
|
+
preserveComments: argv.preserveComments,
|
|
71
|
+
exitOnError: argv.exitOnError
|
|
66
72
|
})
|
|
67
73
|
|
|
68
74
|
nyc.instrumentAllFiles(argv.input, argv.output, function (err) {
|