mirror of
https://github.com/bower/bower.git
synced 2026-02-11 22:44:58 -05:00
42 lines
668 B
JavaScript
42 lines
668 B
JavaScript
// TODO: take care of trailing ,
|
|
|
|
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(JSON.stringify(data, null, ' '));
|
|
}
|
|
|
|
// -------------------------
|
|
|
|
module.exports = {
|
|
head: renderHead,
|
|
tail: renderTail,
|
|
data: renderData,
|
|
error: renderError,
|
|
end: renderEnd
|
|
};
|