Skip to content

Commit

Permalink
fix(snippet): Log UI access urls when in snippet mode
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane committed Mar 30, 2015
1 parent 5b4061e commit c448fa0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,17 @@ module.exports.callbacks = {
if (type === "snippet" && bs.options.get("logSnippet")) {

logger.info(
"Copy the following snippet into your website, " +
"{bold:Copy the following snippet into your website, " +
"just before the closing {cyan:</body>} tag"
);

logger.unprefixed("info",
messages.scriptTags(bs.options)
);

logUrls(bs.options.get("urls").filter(function (value, key) {
return key.slice(0, 2) === "ui";
}).toJS());
}

function serveFiles (base) {
Expand Down Expand Up @@ -185,11 +189,16 @@ module.exports.plugin = function (emitter, bs) {
*/
function logUrls (urls) {

var keys = Object.keys(urls);
var longestName = 0;
var longesturl = 0;
var offset = 2;

var names = Object.keys(urls).map(function (key) {
if (!keys.length) {
return;
}

var names = keys.map(function (key) {
if (key.length > longestName) {
longestName = key.length;
}
Expand All @@ -205,7 +214,7 @@ function logUrls (urls) {
logger.info("{bold:Access URLs:");
logger.unprefixed("info", "{grey: %s", underline);

Object.keys(urls).forEach(function (key, i) {
keys.forEach(function (key, i) {
var keyname = getKeyName(key);
logger.unprefixed("info", " %s: {magenta:%s}",
getPadding(key.length, longestName + offset) + keyname,
Expand Down

0 comments on commit c448fa0

Please sign in to comment.