setup-python/node_modules/@jest/console/build/getConsoleOutput.js

81 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-06-27 03:12:00 +02:00
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _path() {
const data = _interopRequireDefault(require('path'));
_path = function _path() {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function _chalk() {
return data;
};
return data;
}
function _slash() {
const data = _interopRequireDefault(require('slash'));
_slash = function _slash() {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var _default = (root, verbose, buffer) => {
const TITLE_INDENT = verbose ? ' ' : ' ';
const CONSOLE_INDENT = TITLE_INDENT + ' ';
return buffer.reduce((output, {type, message, origin}) => {
origin = (0, _slash().default)(_path().default.relative(root, origin));
message = message
.split(/\n/)
.map(line => CONSOLE_INDENT + line)
.join('\n');
let typeMessage = 'console.' + type;
if (type === 'warn') {
message = _chalk().default.yellow(message);
typeMessage = _chalk().default.yellow(typeMessage);
} else if (type === 'error') {
message = _chalk().default.red(message);
typeMessage = _chalk().default.red(typeMessage);
}
return (
output +
TITLE_INDENT +
_chalk().default.dim(typeMessage) +
' ' +
_chalk().default.dim(origin) +
'\n' +
message +
'\n'
);
}, '');
};
exports.default = _default;