Skip to content

Commit

Permalink
nicer output for browser & launch commands
Browse files Browse the repository at this point in the history
  • Loading branch information
E.Azer Koçulu committed Nov 29, 2014
1 parent 9a45906 commit d8b201e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var errorTemplate = nodeTemplate('browser-error');
var errorNoStackTemplate = nodeTemplate('browser-error-no-stack');
var consoleTemplate = nodeTemplate('browser-console');
var testTemplate = nodeTemplate('browser-test');
var instructionsTemplate = nodeTemplate('browser-instructions');

var onSourceCodeChange = require("pubsub")();
var customFrameURL, matchURL, read;

Expand Down Expand Up @@ -108,7 +110,9 @@ function start (files, command) {

});

debug('Visit %s%s:%s with a browser to start running the tests.', 'http://', command.host, command.port);
//var grep = command.grep ? '/#grep:' + command.grep : '';
//debug('Visit %s%s:%s%s with a browser to start running the tests.', 'http://', command.host, command.port, grep);
outputInstructions(command);

function onMessage (msg) {
msg = JSON.parse(msg.data);
Expand Down Expand Up @@ -293,6 +297,20 @@ function outputResult (msg) {
console.log(formatText(template, msg.result) + ' ' + formatUserAgent(msg.userAgent));
}

function outputInstructions (command) {
var params = '';

if (command.grep) {
params = '/#grep:' + command.grep;
}

console.log(formatText(instructionsTemplate, {
host: command.host,
port: command.port,
params: params
}));
}

function formatUserAgent (rawUserAgent) {
var userAgent = parseUserAgent(rawUserAgent);

Expand Down
14 changes: 10 additions & 4 deletions lib/launch.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
var debug = require("local-debug")('launch');
var launcher = require("browser-launcher");
var style = require("style-format");
var template = require("./node-template")('browser-launch');
var format = require("format-text");

module.exports = launch;
module.exports.list = list;

function list () {
launcher.detect(function (avail) {
console.log(style('\n {bold}Available Browsers:{reset} %s\n'), avail.map(function (b) {
return b.name + ' v' + b.version;
}).join(', '));
console.log(style('\n {cyan}Available Browsers:\n{reset} ' + avail.map(function (b) {
return '\n ' + b.name + ' {grey}v' + b.version + '{reset}';
}).join('')) + '\n');
});
}

Expand All @@ -28,7 +30,11 @@ function launch (url, options) {
if (options.headless) extras += ' headlessly';
if (options.proxy) extras += ' through ' + options.proxy;

debug('Launched %s to visit %s%s.', options.browser, url, extras);
console.log(format(template, {
app: options.browser,
url: url,
extras: extras
}));
});
});
}
2 changes: 1 addition & 1 deletion templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="navigation">
<div class="buttons">
<a class="run-again pointer">Run Again</a>
<a class="run-again pointer">Repeat</a>
<a class="conn" class="pointer">{conn}</a>
<a class="maximize pointer">Maximize Frame</a>
<a class="minimize pointer">Minimize Frame</a>
Expand Down
2 changes: 2 additions & 0 deletions templates/node-browser-instructions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{reset}
{cyan}Visit {reset}{bold}http://{host}:{port}{params}{grey} to run the tests
1 change: 1 addition & 0 deletions templates/node-browser-launch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{reset} {grey}Launching {reset}{bold}{app} {grey}to run the tests{extras}

0 comments on commit d8b201e

Please sign in to comment.