12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 'use strict';
- Object.defineProperty(exports, '__esModule', {
- value: true
- });
- var _path;
- function _load_path() {
- return (_path = _interopRequireDefault(require('path')));
- }
- var _chalk;
- function _load_chalk() {
- return (_chalk = _interopRequireDefault(require('chalk')));
- }
- var _slash;
- function _load_slash() {
- return (_slash = _interopRequireDefault(require('slash')));
- }
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- /**
- * Copyright (c) 2014-present, Facebook, Inc. 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.
- *
- *
- */
- exports.default = (root, verbose, buffer) => {
- const TITLE_INDENT = verbose ? ' ' : ' ';
- const CONSOLE_INDENT = TITLE_INDENT + ' ';
- return buffer.reduce((output, _ref) => {
- let type = _ref.type,
- message = _ref.message,
- origin = _ref.origin;
- origin = (0, (_slash || _load_slash()).default)(
- (_path || _load_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 || _load_chalk()).default.yellow(message);
- typeMessage = (_chalk || _load_chalk()).default.yellow(typeMessage);
- } else if (type === 'error') {
- message = (_chalk || _load_chalk()).default.red(message);
- typeMessage = (_chalk || _load_chalk()).default.red(typeMessage);
- }
- return (
- output +
- TITLE_INDENT +
- (_chalk || _load_chalk()).default.dim(typeMessage) +
- ' ' +
- (_chalk || _load_chalk()).default.dim(origin) +
- '\n' +
- message +
- '\n'
- );
- }, '');
- };
|