Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
re-introduced resemblecontainer. now resolves resemble sub directory
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cryer committed Oct 8, 2014
1 parent 379c7a5 commit 7dc930d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ From the command line/terminal run

### Download

* `npm install phantomcss`
* `npm install phantomcss` (PhantomCSS is not itself a Node.js module)
* `bower install phantomcss`
* `git clone git://github.com/Huddle/PhantomCSS.git`

Expand Down
27 changes: 22 additions & 5 deletions phantomcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ var _failures = '.'+fs.separator+'failures';
var _count = 0;
var _realPath;
var _diffsToProcess = [];
var _libraryRoot = '.'+ fs.separator + 'libs';
var exitStatus;
var _hideElements;
var _addLabelToFailedImage = true;
Expand Down Expand Up @@ -49,9 +48,10 @@ function update(options){
options = options || {};

casper = options.casper || casper;
_libraryRoot = options.libraryRoot || _libraryRoot;

_resemblePath = _libraryRoot+fs.separator+'resemblejs'+fs.separator+'resemble.js';

_resemblePath = getResemblePath(options.libraryRoot || '.');

_resembleContainerPath = (options.libraryRoot || '.') + fs.separator + 'resemblejscontainer.html'

_src = stripslash(options.screenshotRoot || _src);
_results = stripslash(options.comparisonResultRoot || _results || _src);
Expand Down Expand Up @@ -86,6 +86,17 @@ function init(options){
update(options);
}

function getResemblePath(root){
var path = [root,'libs','resemblejs','resemble.js'].join(fs.separator);
if(!fs.isFile(path)){
path = [root,'node_modules','resemblejs','resemble.js'].join(fs.separator);
if(!fs.isFile(path)){
console.log("[PhantomCSS] Screenshot capture failed: ", ex.message);
}
}
return path;
}

function turnOffAnimations(){
console.log('[PhantomCSS] Turning off animations');
casper.evaluate(function turnOffAnimations(){
Expand Down Expand Up @@ -340,7 +351,13 @@ function compareFiles(baseFile, file) {
test.error = true;
} else {

casper.thenOpen ( '<html><head></head><body></body></html>' , function (){
if( !fs.isFile(_resembleContainerPath) ){
console.log('[PhantomCSS] Can\'t find Resemble container. Perhaps the library root is mis configured. ('+_resembleContainerPath+')');
test.error = true;
return;
}

casper.thenOpen ( _resembleContainerPath , function (){

asyncCompare(baseFile, file, function(isSame, mismatch){

Expand Down
1 change: 1 addition & 0 deletions resemblejscontainer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><body>This blank HTML page is used for processing the images with Resemble.js</body></html>

0 comments on commit 7dc930d

Please sign in to comment.