Skip to content

Commit c448fa0

Browse files
committed
fix(snippet): Log UI access urls when in snippet mode
1 parent 5b4061e commit c448fa0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/logger.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,17 @@ module.exports.callbacks = {
135135
if (type === "snippet" && bs.options.get("logSnippet")) {
136136

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

142142
logger.unprefixed("info",
143143
messages.scriptTags(bs.options)
144144
);
145+
146+
logUrls(bs.options.get("urls").filter(function (value, key) {
147+
return key.slice(0, 2) === "ui";
148+
}).toJS());
145149
}
146150

147151
function serveFiles (base) {
@@ -185,11 +189,16 @@ module.exports.plugin = function (emitter, bs) {
185189
*/
186190
function logUrls (urls) {
187191

192+
var keys = Object.keys(urls);
188193
var longestName = 0;
189194
var longesturl = 0;
190195
var offset = 2;
191196

192-
var names = Object.keys(urls).map(function (key) {
197+
if (!keys.length) {
198+
return;
199+
}
200+
201+
var names = keys.map(function (key) {
193202
if (key.length > longestName) {
194203
longestName = key.length;
195204
}
@@ -205,7 +214,7 @@ function logUrls (urls) {
205214
logger.info("{bold:Access URLs:");
206215
logger.unprefixed("info", "{grey: %s", underline);
207216

208-
Object.keys(urls).forEach(function (key, i) {
217+
keys.forEach(function (key, i) {
209218
var keyname = getKeyName(key);
210219
logger.unprefixed("info", " %s: {magenta:%s}",
211220
getPadding(key.length, longestName + offset) + keyname,

0 commit comments

Comments
 (0)