Files
cypress/packages/example/bin/convert.js
Jennifer Shehane 5fc1b5747f Issue 1460 - Update onboarding modal to display split 'examples' specs (#1462)
* Update onboarding dialog to handle new kitchen-sink examples

- Now display ‘integrationExampleFolder’ in messaging instead of file
- Does not display children files of ‘examples’ folder (it’s way too
much) and instead shows ‘examples’ as a closed folder in preview
- Reworded onboarding message to grammatically make sense with folder
- updated finder to open ‘integrationExampleFolder’
- update fixture to reflect new kitchen sink structure.

* bump kitchensink example to 1.0.0

* handle multiple spec files when converting kitchen-sink to example

* handle multiple example spec files when scaffolding

* handle multiple example files in desktop-gui

* update unit tests for new example specs

* fix integration spec
2018-05-11 17:00:02 -04:00

47 lines
1.3 KiB
JavaScript
Executable File

#!/usr/bin/env node
/* eslint-disable quotes */
const fs = require('fs')
const path = require('path')
const glob = require('glob')
const eslintRe = /\/. eslint.+\s+/g
function replaceStringsIn (file) {
fs.readFile(file, 'utf8', function (err, str) {
if (err) throw err
const replace = function (source, dest) {
str = str.split(source).join(dest)
}
replace('http://localhost:8080', 'https://example.cypress.io')
replace("to.eq('localhost:8080')", "to.eq('example.cypress.io')")
replace("to.eq('localhost')", "to.eq('example.cypress.io')")
replace("to.eq('8080')", "to.eq('')")
replace("to.eq('http:')", "to.eq('https:')")
replace(eslintRe, "")
replace("imgSrcToDataURL('/assets", "imgSrcToDataURL('https://example.cypress.io/assets")
fs.writeFile(file, str, function (err) {
if (err) throw err
// eslint-disable-next-line no-console
console.log(`Converted ${path.relative(process.cwd(), file)} successfully.`)
})
})
}
glob('./app/**/*.html', { realpath: true }, (err, htmlFiles) => {
if (err) throw err
glob('./cypress/integration/examples/**/*', { realpath: true }, (err, specFiles) => {
if (err) throw err
htmlFiles.concat(specFiles).forEach(function (file) {
return replaceStringsIn(file)
})
})
})