jsdoc-to-markdown
Advanced tools
Comparing version 2.0.0-alpha.18 to 2.0.0-alpha.19
@@ -22,3 +22,3 @@ 'use strict'; | ||
jsdoc2md._interface = 'cli'; | ||
jsdoc2md.clear().catch(tool.halt); | ||
jsdoc2md.clear().catch(handleError); | ||
} else { | ||
@@ -39,3 +39,3 @@ var _jsdoc2md = require('../../'); | ||
tool.printOutput(cli.usage); | ||
tool.halt(err); | ||
handleError(err); | ||
} | ||
@@ -46,11 +46,11 @@ | ||
tool.printOutput(JSON.stringify(json, null, ' ')); | ||
}).catch(tool.halt); | ||
}).catch(handleError); | ||
} else if (options.jsdoc) { | ||
_jsdoc2md.getJsdocData(options).then(function (json) { | ||
tool.printOutput(JSON.stringify(json, null, ' ')); | ||
}).catch(tool.halt); | ||
}).catch(handleError); | ||
} else if (options.namepaths) { | ||
_jsdoc2md.getNamepaths(options).then(function (namepaths) { | ||
tool.printOutput(JSON.stringify(namepaths, null, ' ')); | ||
}).catch(tool.halt); | ||
}).catch(handleError); | ||
} else { | ||
@@ -62,5 +62,3 @@ var fs = require('fs'); | ||
return process.stdout.write(output); | ||
}).catch(function (err) { | ||
return tool.halt(err, { stack: true }); | ||
}); | ||
}).catch(handleError); | ||
} | ||
@@ -80,4 +78,8 @@ } | ||
} catch (err) { | ||
tool.halt(err, { stack: false }); | ||
handleError(err); | ||
} | ||
} | ||
function handleError(err) { | ||
tool.halt(err.toString()); | ||
} |
@@ -109,3 +109,3 @@ 'use strict'; | ||
metricMap: { | ||
session: 1, | ||
invocation: 1, | ||
source: 2, | ||
@@ -132,3 +132,4 @@ configure: 3, | ||
dimensionMap: { | ||
interface: 4 | ||
interface: 4, | ||
exception: 5 | ||
} | ||
@@ -148,8 +149,10 @@ }); | ||
key: '_hit', | ||
value: function _hit(method, options) { | ||
var metrics = Object.assign({ session: 1 }, options); | ||
value: function _hit(method, options, exception) { | ||
var metrics = Object.assign({ invocation: 1 }, options); | ||
for (var key in metrics) { | ||
metrics[key] = 1; | ||
} | ||
return this._usage.hit({ name: method.name, interface: this._interface }, metrics, this._sendOptions); | ||
var dimensions = { name: method.name, interface: this._interface }; | ||
if (exception) dimensions.exception = exception; | ||
return this._usage.hit(dimensions, metrics, this._sendOptions); | ||
} | ||
@@ -161,11 +164,16 @@ }, { | ||
return Promise.all([this._hit(method, options), method.call(JsdocToMarkdownCore.prototype, options).catch(function (err) { | ||
_this2._usage.exception(err.stack, 1, { | ||
hitParams: new Map([['cd', method.name]]) | ||
options = options || {}; | ||
if (options['no-usage-stats']) this._usage.disable(); | ||
return method.call(JsdocToMarkdownCore.prototype, options).then(function (output) { | ||
return _this2._hit(method, options).then(function () { | ||
return output; | ||
}).catch(function () { | ||
return output; | ||
}); | ||
return _this2._usage.send(_this2._sendOptions).then(function () { | ||
}).catch(function (err) { | ||
return _this2._hit(method, options, err.toString()).then(function () { | ||
throw err; | ||
}).catch(function () { | ||
throw err; | ||
}); | ||
})]).then(function (results) { | ||
return results[1]; | ||
}); | ||
@@ -176,10 +184,11 @@ } | ||
value: function _statsSync(method, options) { | ||
this._hit(method, options); | ||
options = options || {}; | ||
if (options['no-usage-stats']) this._usage.disable(); | ||
try { | ||
return method.call(JsdocToMarkdownCore.prototype, options); | ||
var output = method.call(JsdocToMarkdownCore.prototype, options); | ||
this._hit(method, options); | ||
return output; | ||
} catch (err) { | ||
this._usage.exception(err.stack, 1, { | ||
hitParams: new Map([['cd', method.name]]) | ||
}); | ||
this._usage.send(this._sendOptions).catch(function (err) {}); | ||
this._hit(method, options, err.toString()); | ||
throw err; | ||
} | ||
@@ -186,0 +195,0 @@ } |
{ | ||
"name": "jsdoc-to-markdown", | ||
"author": "Lloyd Brookes", | ||
"version": "2.0.0-alpha.18", | ||
"version": "2.0.0-alpha.19", | ||
"description": "jsdoc-annotated source in, markdown API docs out.", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/jsdoc2md/jsdoc-to-markdown", |
@@ -27,3 +27,3 @@ 'use strict' | ||
jsdoc2md._interface = 'cli' | ||
jsdoc2md.clear().catch(tool.halt) | ||
jsdoc2md.clear().catch(handleError) | ||
} else { | ||
@@ -47,3 +47,3 @@ const jsdoc2md = require('../../') | ||
tool.printOutput(cli.usage) | ||
tool.halt(err) | ||
handleError(err) | ||
} | ||
@@ -57,3 +57,3 @@ | ||
}) | ||
.catch(tool.halt) | ||
.catch(handleError) | ||
@@ -67,3 +67,3 @@ /* jsdoc2md --jsdoc */ | ||
}) | ||
.catch(tool.halt) | ||
.catch(handleError) | ||
@@ -77,3 +77,3 @@ /* jsdoc2md --namepaths */ | ||
}) | ||
.catch(tool.halt) | ||
.catch(handleError) | ||
@@ -88,3 +88,3 @@ /* jsdoc2md [<options>] --src <files> */ | ||
.then(output => process.stdout.write(output)) | ||
.catch(err => tool.halt(err, { stack: true })) | ||
.catch(handleError) | ||
} | ||
@@ -104,4 +104,8 @@ } | ||
} catch (err) { | ||
tool.halt(err, { stack: false }) | ||
handleError(err) | ||
} | ||
} | ||
function handleError (err) { | ||
tool.halt(err.toString()) | ||
} |
@@ -91,3 +91,3 @@ 'use strict' | ||
metricMap: { | ||
session: 1, | ||
invocation: 1, | ||
source: 2, | ||
@@ -114,3 +114,4 @@ configure: 3, | ||
dimensionMap: { | ||
interface: 4 | ||
interface: 4, | ||
exception: 5 | ||
} | ||
@@ -125,36 +126,38 @@ }) | ||
_hit (method, options) { | ||
const metrics = Object.assign({ session: 1 }, options) | ||
_hit (method, options, exception) { | ||
const metrics = Object.assign({ invocation: 1 }, options) | ||
for (const key in metrics) { | ||
metrics[key] = 1 | ||
} | ||
return this._usage.hit({ name: method.name, interface: this._interface }, metrics, this._sendOptions) | ||
const dimensions = { name: method.name, interface: this._interface } | ||
if (exception) dimensions.exception = exception | ||
return this._usage.hit(dimensions, metrics, this._sendOptions) | ||
} | ||
_stats (method, options) { | ||
return Promise.all([ | ||
this._hit(method, options), | ||
method.call(JsdocToMarkdownCore.prototype, options) | ||
.catch(err => { | ||
this._usage.exception(err.stack, 1, { | ||
hitParams: new Map([[ 'cd', method.name ]]) | ||
}) | ||
return this._usage.send(this._sendOptions) | ||
.then(() => { throw err }) | ||
}) | ||
]).then(results => results[1]) | ||
options = options || {} | ||
if (options['no-usage-stats']) this._usage.disable() | ||
return method.call(JsdocToMarkdownCore.prototype, options) | ||
.then(output => { | ||
return this._hit(method, options) | ||
.then(() => output) | ||
.catch(() => output) | ||
}) | ||
.catch(err => { | ||
return this._hit(method, options, err.toString()) | ||
.then(() => { throw err }) | ||
.catch(() => { throw err }) | ||
}) | ||
} | ||
_statsSync (method, options) { | ||
this._hit(method, options) | ||
options = options || {} | ||
if (options['no-usage-stats']) this._usage.disable() | ||
try { | ||
return method.call(JsdocToMarkdownCore.prototype, options) | ||
const output = method.call(JsdocToMarkdownCore.prototype, options) | ||
this._hit(method, options) | ||
return output | ||
} catch (err) { | ||
this._usage.exception(err.stack, 1, { | ||
hitParams: new Map([[ 'cd', method.name ]]) | ||
}) | ||
this._usage.send(this._sendOptions) | ||
.catch(err => { | ||
// catch warning | ||
}) | ||
this._hit(method, options, err.toString()) | ||
throw err | ||
} | ||
@@ -161,0 +164,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67223
1453