mirror of
https://github.com/bower/bower.git
synced 2026-02-11 22:44:58 -05:00
Initial take on the commands + renderers + cli.
This commit is contained in:
38
lib/renderers/json.js
Normal file
38
lib/renderers/json.js
Normal file
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user