This repository has been archived by the owner on Feb 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
// Load in our dependencies | ||
var program = require('commander'); | ||
var pkg = require('../package.json'); | ||
var imageDiff = require('../'); | ||
|
||
// Configure our CLI | ||
program.name = pkg.name; | ||
program | ||
.version(pkg.version) | ||
.usage('[options] <actual-image> <expected-image> [diff-image]') | ||
.option('--shadow', 'Draw a shadow of unchanges parts on diff image') | ||
.action(function handleRun (actualImage, expectedImage, diffImage, program) { | ||
// If there is no program, then assume diffImage was left out | ||
if (program === undefined) { | ||
program = diffImage; | ||
diffImage = undefined; | ||
} | ||
|
||
// Run our diff | ||
imageDiff({ | ||
actualImage: actualImage, | ||
diffImage: diffImage, | ||
expectedImage: expectedImage, | ||
shadow: program.shadow | ||
}, function handleImageDiff (err, imagesAreSame) { | ||
// If there was an error, throw it | ||
if (err) { | ||
throw err; | ||
} | ||
|
||
// Otherwise, exit based on the result | ||
var exitCode = imagesAreSame ? 0 : 1; | ||
process.exit(exitCode); | ||
}); | ||
}); | ||
|
||
// Parse our CLI arguments | ||
program.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters