Skip to content

Commit

Permalink
Merge branch 'bbarwick-fdg-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
james.cryer committed Jan 5, 2016
2 parents e477cec + 9055f60 commit 8a6d05b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ or

### Download

PhantomCSS can be downloaded in various ways:

* `npm install phantomcss` (PhantomCSS is not itself a Node.js module)
* `bower install phantomcss`
* `git clone git://github.com/Huddle/PhantomCSS.git`
Expand Down Expand Up @@ -106,6 +108,12 @@ phantomcss.init({
*/
comparisonResultRoot: './results',

/*
Don't add count number to images. If set to false, a filename is
required when capturing screenshots.
*/
addIteratorToImage: false,

/*
Don't add label to generated failure image
*/
Expand Down
18 changes: 15 additions & 3 deletions phantomcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var _resembleContainerPath;
var _libraryRoot;
var _rebase = false;
var _prefixCount = false;
var _isCount = true;

var _baselineImageSuffix = "";
var _diffImageSuffix = ".diff";
Expand Down Expand Up @@ -73,6 +74,7 @@ function update( options ) {
_fileNameGetter = options.fileNameGetter || _fileNameGetter;

_prefixCount = options.prefixCount || _prefixCount;
_isCount = ( options.addIteratorToImage !== false );

_onPass = options.onPass || _onPass;
_onFail = options.onFail || _onFail;
Expand Down Expand Up @@ -154,12 +156,22 @@ function turnOffAnimations() {
function _fileNameGetter( root, fileName ) {
var name;

// If no iterator, enforce filename.
if ( !_isCount && !fileName ) {
throw 'Filename is required when addIteratorToImage option is false.';
}

fileName = fileName || "screenshot";

if (_prefixCount) {
name = root + fs.separator + _count++ + "_" + fileName;
if ( !_isCount ) {
name = root + fs.separator + fileName;
_count++;
} else {
name = root + fs.separator + fileName + "_" + _count++;
if ( _prefixCount ) {
name = root + fs.separator + _count++ + "_" + fileName;
} else {
name = root + fs.separator + fileName + "_" + _count++;
}
}

if ( _isFile( name + _baselineImageSuffix + '.png' ) ) {
Expand Down

0 comments on commit 8a6d05b

Please sign in to comment.