mirror of
https://github.com/bower/bower.git
synced 2026-02-11 22:44:58 -05:00
40 lines
727 B
JavaScript
40 lines
727 B
JavaScript
var circularJson = require('circular-json');
|
|
|
|
function renderHead() {
|
|
return '[';
|
|
}
|
|
|
|
function renderTail() {
|
|
return ']\n';
|
|
}
|
|
|
|
function renderData(data) {
|
|
return stringify(data) + ', ';
|
|
}
|
|
|
|
function renderError(err) {
|
|
return stringify(err) + ', ';
|
|
}
|
|
|
|
function renderEnd(data) {
|
|
return data ? stringify(data) : '';
|
|
}
|
|
|
|
// -------------------------
|
|
|
|
function uncolor(str) {
|
|
return str.replace(/\x1B\[\d+m/g, '');
|
|
}
|
|
|
|
function stringify(data) {
|
|
return uncolor(circularJson.stringify(data, null, ' '));
|
|
}
|
|
|
|
// -------------------------
|
|
|
|
module.exports.head = renderHead;
|
|
module.exports.tail = renderTail;
|
|
|
|
module.exports.data = renderData;
|
|
module.exports.error = renderError;
|
|
module.exports.end = renderEnd; |