Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
node_modules
34 changes: 17 additions & 17 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true
"node": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true
}
90 changes: 45 additions & 45 deletions cli.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,72 @@ var chalk = require('chalk');
var wraith = require('./index');

function showHelp() {
console.log('A responsive screenshot comparison tool.');
console.log('Based on the Ruby version available at http://github.comm/BBC-News/wraith');
console.log('');
console.log(chalk.underline('Usage'));
console.log(' wraith --config <file>');
console.log('');
console.log(chalk.underline('Example'));
console.log(' wraith --config chrome');
console.log('');
console.log('A responsive screenshot comparison tool.');
console.log('Based on the Ruby version available at http://github.comm/BBC-News/wraith');
console.log('');
console.log(chalk.underline('Usage'));
console.log(' wraith --config <file>');
console.log('');
console.log(chalk.underline('Example'));
console.log(' wraith --config chrome');
console.log('');
}

function getStdin(cb) {
var ret = '';
var ret = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (data) {
ret += data;
});
process.stdin.on('data', function (data) {
ret += data;
});

process.stdin.on('end', function () {
cb(ret);
});
process.stdin.on('end', function () {
cb(ret);
});
}

function init(args) {
if (opts.help) {
return showHelp();
}
if (opts.help) {
return showHelp();
}

if (opts.version) {
return console.log(require('./package').version);
}
if (opts.version) {
return console.log(require('./package').version);
}

var config = args;
if( opts.config && args[0]) {
if (config.length === 0) {
console.error(chalk.yellow('You must specifiy a configuration file'));
return showHelp();
} else {
return wraith.run(args[0]);
}
}
var config = args;
if (opts.config && args[0]) {
if (config.length === 0) {
console.error(chalk.yellow('You must specifiy a configuration file'));
return showHelp();
} else {
return wraith.run(args[0]);
}
}

return showHelp();
return showHelp();
}

var opts = nopt({
help: Boolean,
version: Boolean,
config: Boolean
help: Boolean,
version: Boolean,
config: Boolean
}, {
h: '--help',
v: '--version',
c: '--config'
h: '--help',
v: '--version',
c: '--config'
});

var args = opts.argv.remain;

if (process.stdin.isTTY) {
init(args);
init(args);
} else {
getStdin(function (data) {
[].push.apply(args, data.trim().split('\n'));
init(args);
});
getStdin(function (data) {
[].push.apply(args, data.trim().split('\n'));
init(args);
});
}

25 changes: 25 additions & 0 deletions config/bbc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"project": "Test",
"domains": {
"bbc.co.uk": "http://www.bbc.co.uk",
"live.bbc.co.uk": "http://www.live.bbc.co.uk"
},
"engines": [
"phantomjs"
],
"sizes": [
"320",
"768",
"1440"
],
"outputDir": "bbc",
"paths": [
"/",
"/news",
"/weather",
"/tv",
"/aboutthebbc"
],
"fuzz": "20%",
"maxConnections": 20
}
25 changes: 0 additions & 25 deletions config/chrome.json

This file was deleted.

47 changes: 47 additions & 0 deletions config/config.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"#": "(Optional name for the project, if supplied it will be used within the generated gallery only)",
"project": "Test",

"#": "Specify one or two domains",
"domains": {
"bbb.co.uk": "http://www.bbc.co.uk",
"live.bbc.co.uk": "http://live.bbc.co.uk"
},

"#": "Engines supported are phantomjs, slimerjs and triflejs but in theory any phantomjs based headless browser can be supported via a custom snap.js file",
"engines": [
"phantomjs"
],

"#": "Specify as many sizes as you wish",
"sizes": [
"320",
"768",
"1440"
],

"#": "(Defaults to 'shots' directory)",
"outputDir": "test/chrome/",

"#": "You can choose to specify a list of paths to be used or you can crawl the site. If paths are provided they will take precedent and the spider file will be ignored.",
"paths": [
"/",
"/news/",
"/news/local/",
"/news/england/york_and_north_yorkshire/",
"/weather/"
],

"#": "If no paths are specified then a site crawl will take place and the results will be save in the location specified within this option",
"#": "(Specify which file should be used for the spider txt file)",
"spider": "spider/test.txt",

"#": "(Specify snap.js which is used to take the screenshots. Defaults to 'snap.js')",
"snap": "snap/test/chrome.js",

"#": "(Adjusts the sensitivity of the image comparison)",
"fuzz": "20%",

"#": "(Limit the amount of concurrent processes)",
"maxConnections": 20
}
16 changes: 16 additions & 0 deletions config/defaults.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"project": "",
"engines": [
"phantomjs"
],
"sizes": [
"720"
],
"outputDir": "shots/",
"paths": [
"/"
],
"snap": "snap.js",
"fuzz": "20%",
"maxConnections": 20
}
21 changes: 21 additions & 0 deletions config/google.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"project": "Google Test",
"domains": {
"usa": "http://www.google.com",
"canada": "http://www.google.ca"
},
"engines": [
"phantomjs"
],
"sizes": [
"768",
"1440"
],
"outputDir": "test",
"paths": [
"/",
"/404"
],
"fuzz": "20%",
"maxConnections": 20
}
Loading