Files
cypress/scripts/add_newlines_to_snapshots.js
T
Amir Rustamzadeh f313dd0b84 iterate through specs in parallel (#2154)
- fixes: #2153
- fixes: #1566
- fixes: #1690
- fixes: #2275
- fixes: #2276
2018-08-06 07:24:19 -04:00

27 lines
606 B
JavaScript

const fs = require('fs-extra')
const glob = require('glob')
const Promise = require('bluebird')
const globAsync = Promise.promisify(glob)
const endingNewLines = /\s+$/g
const contentBetweenBackticksRe = /\`([\s\S]+?)\`/g
globAsync('packages/server/__snapshots__/*')
.map((file) => {
return fs.readFile(file, 'utf8')
.then((str) => {
return str
.replace(
contentBetweenBackticksRe,
'`\n$1\n`'
)
.split('`\n\n\n').join('`\n\n')
.split('\n\n\n\n`').join('\n\n\n`')
.split(endingNewLines).join('\n')
})
.then((str) => {
return fs.writeFile(file, str)
})
})