Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wraith

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wraith - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

snap.js

2

index.js

@@ -21,3 +21,3 @@ 'use strict';

for(var domain in config.domains) {
domains.push(config.domains[domain]);
domains.push(config.domains[domain].replace(/\/+$/, ''));
domainLabels.push(domain);

@@ -24,0 +24,0 @@ }

@@ -11,3 +11,3 @@ 'use strict';

compareList = compareList.sort(helpers.sortByProp('sort'));
var template = __dirname + './gallery.html',
var template = __dirname + '/../gallery.html',
view = {

@@ -14,0 +14,0 @@ 'images' : compareList,

'use strict';
var rimraf = require('rimraf');
module.exports.sortByProp = sortByProp;

@@ -14,2 +16,15 @@

};
}
module.exports.emptyFolder = emptyFolder;
function emptyFolder(folder, cb) {
if( typeof(folder) === 'undefined' ) { return false; }
rimraf(folder, function(err) {
if( err ) { throw err; }
cb();
});
return true;
}

@@ -12,33 +12,44 @@ 'use strict';

console.log('Crawl of ' + url + ' started');
mkdirp(file, function (err) {
if (err) { throw err; }
crawl.crawl(url, { headers: false, body: false }, function(err, pages) {
if (err) {
console.error('An error occured', err);
return;
}
crawl.crawl(url, { headers: false, body: false }, function(err, pages) {
var txt = '',
pagesLength = pages.length,
link = '';
if (err) {
console.error('An error occured', err);
return;
}
for(var i = 0; i<pagesLength; i++) {
link = pages[i].url;
if(link.indexOf(url) === 0) {
txt += link.replace(url, '') + '\n';
}
var txt = '',
pagesLength = pages.length,
link = '';
for(var i = 0; i<pagesLength; i++) {
link = pages[i].url;
var excPattern = new RegExp('.(css|js|jpg|jpeg|png|pdf|doc|xls|xlsx|ppt|txt|gif|swf|svg|ttf|otf|woff|json|xml)+$');
if(link.indexOf(url) === 0 && !link.match(excPattern)) {
txt += link.replace(url, '') + '\n';
}
txt = txt.trim();
}
txt = txt.trim();
fs.writeFile(file, txt, function(err) {
if(err) {
console.log(err);
} else {
console.log('Spider file saved to ' + file);
callback();
}
if( txt.length > 0 ) {
var folders = file.split('/');
folders.pop();
folders = folders.join('/');
mkdirp(folders, function (err) {
if (err) { throw err; }
fs.writeFile(file, txt, function(err) {
if(err) {
console.log(err);
} else {
console.log('Spider file saved to ' + file);
callback();
}
});
});
});
} else {
console.log('No urls found');
}
});
}

@@ -7,3 +7,4 @@ 'use strict';

gallery = require('./gallery'),
screenshot = require('./screenshot');
screenshot = require('./screenshot'),
helpers = require('./helpers');

@@ -23,104 +24,115 @@ module.exports = wraith;

} else {
fs.readFileSync(config.spider, 'utf8').split('\n');
urls = fs.readFileSync(config.spider, 'utf8').split('\n');
}
var foldersQueue = async.queue(function(folder, callback) {
mkdirp(folder, function (err) {
if (err) { throw err; }
callback();
});
});
if( urls.length > 0 ) {
for(var url in urls) {
folder = outputFolder + urls[url].substring(1).replace(/\/+$/,'') + '/';
foldersQueue.push(folder);
dirs.push(folder);
}
helpers.emptyFolder(outputFolder, function () {
foldersQueue.drain = function() {
console.log('Folders created');
console.log('Cleaned up old folders and files');
var screenshotQueue = async.queue(function (task, callback) {
screenshot.take(task.engine, task.snapFile, task.url, task.size, task.output, callback);
}, config.maxConnections);
var foldersQueue = async.queue(function(folder, callback) {
mkdirp(folder, function (err) {
if (err) { throw err; }
callback();
});
});
var url, size;
for(var url in urls) {
folder = outputFolder + urls[url].substring(1).replace(/\/+$/,'') + '/';
foldersQueue.push(folder);
dirs.push(folder);
}
if( engines.length === 1 ) {
for(var domain in domains) {
for(url in urls) {
imageUrls.push(domains[domain] + urls[url]);
folder = outputFolder + urls[url].substring(1).replace(/\/+$/,'') + '/';
for(size in sizes) {
image = folder + domainLabels[domain] + '_' + sizes[size] + '.png';
screenshotQueue.push({
engine: engines[0],
snapFile: config.snap,
url: domains[domain] + urls[url],
size: sizes[size],
output: image
});
foldersQueue.drain = function() {
console.log('New folders created');
var screenshotQueue = async.queue(function (task, callback) {
screenshot.take(task.engine, task.snapFile, task.url, task.size, task.output, callback);
}, config.maxConnections);
var url, size;
if( engines.length === 1 ) {
for(var domain in domains) {
for(url in urls) {
imageUrls.push(domains[domain] + urls[url]);
folder = outputFolder + urls[url].substring(1).replace(/\/+$/,'') + '/';
for(size in sizes) {
image = folder + domainLabels[domain] + '_' + sizes[size] + '.png';
screenshotQueue.push({
engine: engines[0],
snapFile: config.snap,
url: domains[domain] + urls[url],
size: sizes[size],
output: image
});
}
}
}
}
}
} else {
for(url in urls) {
for(var engine in engines) {
imageUrls.push(domains[0] + urls[url]);
folder = outputFolder + urls[url].substring(1).replace(/\/+$/,'') + '/';
for(size in sizes) {
image = folder + engines[engine] + '_' + sizes[size] + '.png';
screenshotQueue.push({
engine: engines[engine],
snapFile: config.snap,
url: domains[0] + urls[url],
size: sizes[size],
output: image
});
} else {
for(url in urls) {
for(var engine in engines) {
imageUrls.push(domains[0] + urls[url]);
folder = outputFolder + urls[url].substring(1).replace(/\/+$/,'') + '/';
for(size in sizes) {
image = folder + engines[engine] + '_' + sizes[size] + '.png';
screenshotQueue.push({
engine: engines[engine],
snapFile: config.snap,
url: domains[0] + urls[url],
size: sizes[size],
output: image
});
}
}
}
}
}
}
screenshotQueue.drain = function() {
console.log('Screenshots done');
screenshotQueue.drain = function() {
console.log('Screenshots done');
var compareQueue = async.queue(function(task, callback) {
screenshot.compare(task.base, task.compare, task.output, task.diff, task.fuzz, callback);
}, config.maxConnections);
var compareQueue = async.queue(function(task, callback) {
screenshot.compare(task.base, task.compare, task.output, task.diff, task.fuzz, callback);
}, config.maxConnections);
folder = '';
var fileLabels = [], compareList = [], item;
folder = '';
var fileLabels = [], compareList = [], item;
if( engines.length === 1 ) {
fileLabels = [domainLabels[0], domainLabels[1]];
} else {
fileLabels = [engines[0], engines[1]];
}
if( engines.length === 1 ) {
fileLabels = [domainLabels[0], domainLabels[1]];
} else {
fileLabels = [engines[0], engines[1]];
}
for(var url in urls) {
var dir = urls[url].substring(1).replace(/\/+$/,'') + '/';
folder = outputFolder + dir;
for(var size in sizes) {
item = {
'dir': ( size > 0 ? false : folder),
'sort': folder + size,
'base': folder + fileLabels[0] + '_' + sizes[size] + '.png',
'compare': folder + fileLabels[1] + '_' + sizes[size] + '.png',
'output': folder + sizes[size] + '_diff.png',
'diff': folder + sizes[size] + '_diff.txt',
'fuzz': config.fuzz,
'size': sizes[size]
for(var url in urls) {
var dir = urls[url].substring(1).replace(/\/+$/,'') + '/';
folder = outputFolder + dir;
for(var size in sizes) {
item = {
'dir': ( size > 0 ? false : folder),
'sort': folder + size,
'base': folder + fileLabels[0] + '_' + sizes[size] + '.png',
'compare': folder + fileLabels[1] + '_' + sizes[size] + '.png',
'output': folder + sizes[size] + '_diff.png',
'diff': folder + sizes[size] + '_diff.txt',
'fuzz': config.fuzz,
'size': sizes[size]
};
compareQueue.push(item);
compareList.push(item);
}
}
compareQueue.drain = function(){
console.log('Image comparison done');
gallery.generate(dirs, compareList, outputFolder, config.project, cb);
};
compareQueue.push(item);
compareList.push(item);
}
}
compareQueue.drain = function(){
console.log('Image comparison done');
gallery.generate(dirs, compareList, outputFolder, config.project, cb);
};
};
};
};
});
} else {
console.log('No url(s) provided');
return false;
}
}
{
"name": "wraith",
"version": "0.2.5",
"version": "0.2.6",
"description": "A responsive screenshot comparison tool. Based on the Ruby version available at http://github.comm/BBC-News/wraith",

@@ -23,3 +23,4 @@ "license": "MIT",

"lib/*",
"gallery.html"
"gallery.html",
"snap.js"
],

@@ -49,5 +50,6 @@ "keywords": [

"mkdirp": "~0.3.5",
"mustache": "~0.8.1"
"mustache": "~0.8.1",
"rimraf": "~2.2.6"
},
"devDependencies": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc