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 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
- var _this = this
272
- var instrumenter = this.instrumenter()
273
- var instrumented
273
+ const instrumenter = this.instrumenter()
274
+ let instrumented
274
275
 
275
- return function (code, metadata, hash) {
276
- var filename = metadata.filename
277
- var sourceMap = null
276
+ return (code, metadata, hash) => {
277
+ const filename = metadata.filename
278
+ let sourceMap = null
278
279
 
279
- if (_this._sourceMap) sourceMap = _this.sourceMaps.extractAndRegister(code, filename, hash)
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
- instrumented = code
286
+ if (this.config.exitOnError) {
287
+ process.exit(1)
288
+ } else {
289
+ instrumented = code
290
+ }
287
291
  }
288
292
 
289
- if (_this.fakeRequire) {
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nyc",
3
- "version": "11.8.0",
3
+ "version": "11.9.0",
4
4
  "description": "the Istanbul command line interface",
5
5
  "main": "index.js",
6
6
  "scripts": {