56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
|
|
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
|
|
|
|
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
|
|
|
|
var _chalk = require('chalk');
|
|
|
|
var _chalk2 = _interopRequireDefault(_chalk);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function log(data) {
|
|
var args = Array.prototype.slice.call(arguments, 0);
|
|
|
|
respectProgressBars(function () {
|
|
var _console;
|
|
|
|
(_console = console).log.apply(_console, (0, _toConsumableArray3.default)(args));
|
|
});
|
|
}
|
|
|
|
log.withTimestamp = function (data) {
|
|
var prefix = _chalk2.default.dim(new Date().toLocaleTimeString()) + ':';
|
|
var args = [prefix].concat(Array.prototype.slice.call(arguments, 0));
|
|
|
|
respectProgressBars(function () {
|
|
var _console2;
|
|
|
|
(_console2 = console).log.apply(_console2, (0, _toConsumableArray3.default)(args));
|
|
});
|
|
};
|
|
|
|
var _bundleProgressBar = void 0;
|
|
log.setBundleProgressBar = function (bundleProgressBar) {
|
|
_bundleProgressBar = bundleProgressBar;
|
|
};
|
|
|
|
function respectProgressBars(commitLogs) {
|
|
if (_bundleProgressBar) {
|
|
_bundleProgressBar.terminate();
|
|
_bundleProgressBar.lastDraw = '';
|
|
commitLogs();
|
|
_bundleProgressBar.render();
|
|
} else {
|
|
commitLogs();
|
|
}
|
|
}
|
|
|
|
exports.default = log;
|
|
module.exports = exports['default'];
|
|
//# sourceMappingURL=log.js.map
|