@cake-hub/cake-screenshot_diffs
Version:
A CAKE Screenshot diffing tool that includes a setup to comapre two given resources by screenshots taken from the available pages.
38 lines (33 loc) • 1.22 kB
JavaScript
const yargs = require ("yargs");
const fs = require ("fs-extra");
const BackstopConfiguration = require ("./src/backstop-configuration");
const CakeScreenshotDiff = require ("./index");
const PackageJson = require ("./package.json");
const defaultConfigurationFilePath = "./cake-screenshot.yml";
// Read the CLI parameters
const argv = yargs
// Configuration path parameter
.alias ("config", "configurationPath")
.nargs("config", 1)
.describe("config", "The path to your configuration file in YAML format.")
.check((argv) => {
const configPath = BackstopConfiguration.preparePath (argv.config, defaultConfigurationFilePath);
if (!fs.existsSync (configPath)) {
throw new Error ("The configPathuration file can not be opened at location: " + configPath);
}
return true;
})
// Help parameter
.help("h")
.alias("h", "help").argv;
(async () => {
try {
await CakeScreenshotDiff (
BackstopConfiguration.preparePath (argv.config, defaultConfigurationFilePath)
);
} catch (e) {
// Deal with the fact the chain failed
console.error ("ERROR", PackageJson.name, e);
}
})();