Comparing version 1.0.1 to 1.0.2
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
function printFilenames(results) { | ||
function printFilenames (results) { | ||
results.similarImages.forEach(function (filename) { | ||
@@ -28,3 +28,3 @@ console.log(chalk.green('√ ' + filename)) | ||
if (args.h === 'config' || args.help === 'config') { | ||
return fs.createReadStream(__dirname + '/configOptions.txt') | ||
fs.createReadStream(__dirname + '/configOptions.txt') | ||
.pipe(process.stdout) | ||
@@ -35,3 +35,3 @@ .on('close', function () { | ||
} else { | ||
return fs.createReadStream(__dirname + '/usage.txt') | ||
fs.createReadStream(__dirname + '/usage.txt') | ||
.pipe(process.stdout) | ||
@@ -42,45 +42,45 @@ .on('close', function () { | ||
} | ||
} | ||
if (!(args.c || args.config)) { | ||
console.error('You need to pass a configuration object') | ||
process.exit(1) | ||
} | ||
fs.readFile(args.config || args.c, function (err, data) { | ||
if (err) { | ||
console.error(err) | ||
} else { | ||
if (!(args.c || args.config)) { | ||
console.error('You need to pass a configuration object') | ||
process.exit(1) | ||
} | ||
try { | ||
var config = JSON.parse(data) | ||
fs.readFile(args.config || args.c, function (err, data) { | ||
if (err) { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
stranger(config, (args.generate || args.g), function (results) { | ||
console.log('') | ||
try { | ||
var config = JSON.parse(data) | ||
if (!results.imagesProcessed && results.imagesGenerated) { | ||
return console.log(chalk.green(results.imagesGenerated + ' ' + (results.imagesGenerated === 1 ? 'screenshot' : 'screenshots') + ' created and placed in ' + results.imagesDir)) | ||
} | ||
stranger(config, (args.generate || args.g), function (results) { | ||
console.log('') | ||
printFilenames(results) | ||
if (!results.imagesProcessed && results.imagesGenerated) { | ||
return console.log(chalk.green(results.imagesGenerated + ' ' + (results.imagesGenerated === 1 ? 'screenshot' : 'screenshots') + ' created and placed in ' + results.imagesDir)) | ||
} | ||
if (!results.noMatchCount && !results.diffCount) { | ||
return console.log(chalk.green('No diffs found!')) | ||
} | ||
printFilenames(results) | ||
if (results.noMatchCount) { | ||
console.warn(chalk.yellow('There ' + (results.noMatchCount === 1 ? 'was' : 'were') + ' ' + results.noMatchCount + ' ' + (results.noMatchCount === 1 ? 'image' : 'images') + ' that didn\'t have a reference image.\n') + 'It\'s recommended that you re-run stranger with the ' + chalk.yellow('--generate') + ' flag.') | ||
} | ||
if (!results.noMatchCount && !results.diffCount) { | ||
return console.log(chalk.green('No diffs found!')) | ||
} | ||
if (results.diffCount) { | ||
console.error(chalk.yellow(results.diffCount + ' ' + (results.diffCount === 1 ? 'diff' : 'diffs') + ' found! Check out the ' + results.diffDir + ' directory for the ' + (results.diffCount === 1 ? 'diff' : 'diffs') + '.')) | ||
if (results.noMatchCount) { | ||
console.warn(chalk.yellow('There ' + (results.noMatchCount === 1 ? 'was' : 'were') + ' ' + results.noMatchCount + ' ' + (results.noMatchCount === 1 ? 'image' : 'images') + ' that didn\'t have a reference image.\n') + 'It\'s recommended that you re-run stranger with the ' + chalk.yellow('--generate') + ' flag.') | ||
} | ||
process.exit(1) | ||
} | ||
}) | ||
} catch (err) { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
}) | ||
if (results.diffCount) { | ||
console.error(chalk.yellow(results.diffCount + ' ' + (results.diffCount === 1 ? 'diff' : 'diffs') + ' found! Check out the ' + results.diffDir + ' directory for the ' + (results.diffCount === 1 ? 'diff' : 'diffs') + '.')) | ||
process.exit(1) | ||
} | ||
}) | ||
} catch (err) { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
}) | ||
} |
{ | ||
"name": "stranger", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A visual regression testing framework for node.js", | ||
@@ -25,3 +25,3 @@ "main": "sranger.js", | ||
"chalk": "^1.1.0", | ||
"del": "^1.2.0", | ||
"del": "^2.0.2", | ||
"gm": "^1.18.1", | ||
@@ -36,2 +36,3 @@ "mkdirp": "^0.5.1", | ||
"pre-commit": "^1.0.10", | ||
"standard": "^5.3.1", | ||
"tap-spec": "^4.0.2", | ||
@@ -38,0 +39,0 @@ "tape": "^4.0.0", |
@@ -24,3 +24,11 @@ stranger | ||
It's imperative that you have both imagemagick and graphicsmagick installed. If you're running OS X, we recommend using [brew](http://brew.sh) to install them. | ||
```shell | ||
# If you have brew | ||
brew install imagemagick | ||
brew install graphicsmagick | ||
``` | ||
```shell | ||
npm install -g stranger | ||
@@ -27,0 +35,0 @@ ``` |
@@ -65,8 +65,6 @@ var fs = require('fs') | ||
if (!self.generateImages) { | ||
del(self.config.diffDir + '**/*', function (err) { | ||
if (err) { | ||
throw new Error(err) | ||
} | ||
del(self.config.diffDir + '**/*').then(function () { | ||
self.compareImages() | ||
}).catch(function (err) { | ||
throw new Error(err) | ||
}) | ||
@@ -223,3 +221,3 @@ } | ||
Stranger.prototype.createFilename = function (test) { | ||
var filename = test.name || test.url.split('/')[ test.url.split('/').length - 1] || 'index' | ||
var filename = test.name || test.url.split('/')[test.url.split('/').length - 1] || 'index' | ||
@@ -226,0 +224,0 @@ return filename + '.png' |
@@ -89,3 +89,3 @@ 'use strict' | ||
test('The tool fails if no base images have been generated', function (t) { | ||
del('./test/img/**/*.png', function (err) { | ||
del('./test/img/**/*.png').then(function () { | ||
var stranger = spawn('./bin/cmd.js', [ | ||
@@ -98,6 +98,2 @@ '--config', | ||
if (err) { | ||
t.fail(err) | ||
} | ||
stranger.stdout.on('data', function (stdout) { | ||
@@ -115,2 +111,5 @@ t.notOk(stdout, 'The error text wasn\'t printed to stdout') | ||
}) | ||
}).catch(function (err) { | ||
process.stdout.write(err) | ||
t.fail(err) | ||
}) | ||
@@ -120,3 +119,3 @@ }) | ||
test('The tool generates a diff', function (t) { | ||
del('./test/img/deskop/**/*', function (err) { | ||
del('./test/img/deskop/**/*').then(function () { | ||
var stranger = spawn('./bin/cmd.js', [ | ||
@@ -130,6 +129,2 @@ '--config', | ||
if (err) { | ||
t.fail(err) | ||
} | ||
stranger.on('close', function (code) { | ||
@@ -145,6 +140,2 @@ t.equal(code, 0, 'It exited with a 0 status') | ||
if (err) { | ||
t.fail(err) | ||
} | ||
stranger2.stdout.on('data', function (stdout) { | ||
@@ -163,2 +154,5 @@ t.ok(stdout.toString(), 'The good image\'s filename was printed') | ||
}) | ||
}).catch(function (err) { | ||
process.stdout.write(err) | ||
t.fail(err) | ||
}) | ||
@@ -168,3 +162,3 @@ }) | ||
test('The tool doesn\'t generate a diff', function (t) { | ||
del('./test/img/deskop/**/*', function (err) { | ||
del('./test/img/deskop/**/*').then(function () { | ||
var stranger = spawn('./bin/cmd.js', [ | ||
@@ -178,6 +172,2 @@ '--config', | ||
if (err) { | ||
t.fail(err) | ||
} | ||
stranger.on('close', function (code) { | ||
@@ -193,6 +183,2 @@ t.equal(code, 0, 'It exited with a 0 status') | ||
if (err) { | ||
t.fail(err) | ||
} | ||
stranger2.stdout.on('data', function (stdout) { | ||
@@ -211,2 +197,5 @@ t.ok(stdout.toString(), 'The diff message message was generated') | ||
}) | ||
}).catch(function (err) { | ||
process.stdout.write(err) | ||
t.fail(err) | ||
}) | ||
@@ -216,3 +205,3 @@ }) | ||
test('The tool warns the user if there\'s a mismatch', function (t) { | ||
del('./test/img/deskop/**/*', function (err) { | ||
del('./test/img/deskop/**/*').then(function () { | ||
var stranger = spawn('./bin/cmd.js', [ | ||
@@ -226,6 +215,2 @@ '--config', | ||
if (err) { | ||
t.fail(err) | ||
} | ||
stranger.on('close', function (code) { | ||
@@ -241,6 +226,2 @@ t.equal(code, 0, 'It exited with a 0 status') | ||
if (err) { | ||
t.fail(err) | ||
} | ||
stranger2.stdout.on('data', function (stdout) { | ||
@@ -259,2 +240,5 @@ t.ok(stdout.toString(), 'The images without a diff were printed') | ||
}) | ||
}).catch(function (err) { | ||
process.stdout.write(err) | ||
t.fail(err) | ||
}) | ||
@@ -264,3 +248,3 @@ }) | ||
test('The tool makes the filename match the URL or the name', function (t) { | ||
del('./test/img/deskop/**/*', function (err) { | ||
del('./test/img/deskop/**/*').then(function () { | ||
spawn('./bin/cmd.js', [ | ||
@@ -274,6 +258,2 @@ '--config', | ||
if (err) { | ||
t.fail(err) | ||
} | ||
fs.readdir('./test/img/desktop/master', function (err, paths) { | ||
@@ -289,3 +269,6 @@ if (err) { | ||
}) | ||
}).catch(function (err) { | ||
process.stdout.write(err) | ||
t.fail(err) | ||
}) | ||
}) |
@@ -18,3 +18,3 @@ 'use strict' | ||
test('The tool fails if no base images have been generated', function (t) { | ||
del('./test/img/**/*.png', function () { | ||
del('./test/img/**/*.png').then(function () { | ||
t.throws(function () { | ||
@@ -28,3 +28,3 @@ stranger(basicConfig, false) | ||
test('The tool generates the base images', function (t) { | ||
del('./test/img/**/*.png', function () { | ||
del('./test/img/**/*.png').then(function () { | ||
stranger(basicConfig, true, function (results) { | ||
@@ -42,3 +42,3 @@ t.ok(results, 'It send the results through') | ||
test('The tool compares similar images', function (t) { | ||
del('./test/img/**/*.png', function () { | ||
del('./test/img/**/*.png').then(function () { | ||
stranger(basicConfig, true, function () { | ||
@@ -64,3 +64,3 @@ stranger(basicConfig, false, function (results) { | ||
test('The tool finds a diff', function (t) { | ||
del('./test/img/**/*.png', function () { | ||
del('./test/img/**/*.png').then(function () { | ||
stranger(basicConfig, true, function () { | ||
@@ -86,3 +86,3 @@ stranger(diffableConfig, false, function (results) { | ||
test('The tool finds a diff', function (t) { | ||
del('./test/img/**/*.png', function () { | ||
del('./test/img/**/*.png').then(function () { | ||
stranger(basicConfig, true, function () { | ||
@@ -89,0 +89,0 @@ stranger(mismatchConfig, false, function (results) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
181
270607
7
918
2
+ Addedarrify@1.0.1(transitive)
+ Addeddel@2.2.2(transitive)
+ Addedglobby@5.0.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedpify@2.3.0(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
- Removedasync@1.5.2(transitive)
- Removeddel@1.2.1(transitive)
- Removedeach-async@1.1.1(transitive)
- Removedglob@5.0.15(transitive)
- Removedglobby@2.1.0(transitive)
- Removedobject-assign@3.0.0(transitive)
- Removedonetime@1.1.0(transitive)
- Removedset-immediate-shim@1.0.1(transitive)
Updateddel@^2.0.2