Created
December 20, 2019 15:18
-
-
Save MadRiver44/820eae6a9e200285ffc1bbb5468cdc48 to your computer and use it in GitHub Desktop.
Create a .json file from reading backstop.yml file -- updateConfig.js
This file contains hidden or 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 script creates a `backstop.json` file from `backstop.yml` and all <label>.yml files included in scenarios directory | |
| * `backstop.json` is a configuration file that BackstopJS uses to create screenshots of components | |
| * | |
| */ | |
| const fs = require('fs') | |
| const path = require('path') | |
| const yaml = require('js-yaml') | |
| const backstopJSON = yaml.load(fs.readFileSync(path.resolve('./backstop.yml'))) | |
| backstopJSON.scenarios = fs | |
| .readdirSync(path.resolve('backstop_data', 'scenarios')) | |
| .filter(file => file.match(/\.yml/i)) | |
| .map(file => yaml.load(fs.readFileSync(path.resolve('backstop_data', 'scenarios', file)))) | |
| fs.writeFileSync(path.join('./backstop.json'), JSON.stringify(backstopJSON, null, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment