Print only the stack trace when verbose or the error has no code (usually something strange).

This commit is contained in:
André Cruz
2013-06-02 11:49:01 +01:00
parent 12078f07c6
commit e811236973
3 changed files with 9 additions and 8 deletions

View File

@@ -4,7 +4,7 @@ var template = require('../util/template');
var wideCommands = ['install', 'update'];
function StandardRenderer(command, colorful) {
function StandardRenderer(command, config) {
this._sizes = {
id: 10, // Id max chars
label: 23, // Label max chars
@@ -18,7 +18,7 @@ function StandardRenderer(command, colorful) {
};
this._command = command;
this._colorful = colorful == null ? true : colorful;
this._config = config;
if (wideCommands.indexOf(command) === -1) {
this._compact = true;
@@ -48,8 +48,8 @@ StandardRenderer.prototype.error = function (err) {
str += mout.string.trim(err.details) + '\n';
}
// Print stack if the error is not skippable
if (!err.skippable) {
// Print stack if verbose or the error has no code
if (this._config.verbose || !err.code) {
str += '\n' + err.stack + '\n';
}
@@ -177,7 +177,7 @@ StandardRenderer.prototype._prefixNotification = function (notification) {
};
StandardRenderer.prototype._write = function (stream, str) {
if (!this._colorful) {
if (!this._config.color) {
str = str.replace(/\x1B\[\d+m/g, '');
}

View File

@@ -39,10 +39,10 @@ function readOptions(options, argv) {
function getRenderer(command, config) {
if (config.json) {
return new renderers.Json(command);
return new renderers.Json(command, config);
}
return new renderers.Standard(command, config.color);
return new renderers.Standard(command, config);
}
module.exports.readOptions = readOptions;

View File

@@ -6,6 +6,7 @@ var tar = require('tar');
var Q = require('q');
var mout = require('mout');
var junk = require('junk');
var createError = require('./createError');
// This forces the default chunk size to something small in an attempt
// to avoid issue #314
@@ -153,7 +154,7 @@ function extract(src, dest, opts) {
// If extractor is null, then the archive type is unknown
if (!extractor) {
return Q.reject(new Error('File "' + src + '" is not a known archive'));
return Q.reject(createError('File "' + src + '" is not a known archive', 'ENOTARCHIVE'));
}
// Extract archive