File tree Expand file tree Collapse file tree 3 files changed +32
-32
lines changed
e2e-tests/development-runtime
cypress/integration/functionality Expand file tree Collapse file tree 3 files changed +32
-32
lines changed Original file line number Diff line number Diff line change 11const TEST_ELEMENT = `test-element`
22
3- after ( ( ) => {
3+ before ( ( ) => {
44 cy . exec ( `npm run reset` )
55} )
66
@@ -43,33 +43,8 @@ describe(`babelrc`, () => {
4343 . invoke ( `text` )
4444 . should ( `eq` , `babel-rc-test` )
4545
46- const FILE_CONTENT = `
47- {
48- "plugins": [
49- [
50- "babel-plugin-search-and-replace",
51- {
52- "rules": [
53- {
54- "search": "babel-rc-test",
55- "replace": "babel-rc-added",
56- "searchTemplateStrings": true
57- }
58-
59- ]
60- }
61- ]
62- ],
63- "presets": [
64- "babel-preset-gatsby"
65- ]
66- }
67- `
68-
6946 cy . exec (
70- `npm run update -- --file src/pages/babelrc/add/.babelrc --file-content '${ JSON . stringify (
71- FILE_CONTENT
72- ) } '`
47+ `npm run update -- --file src/pages/babelrc/add/.babelrc --file-source src/pages/babelrc/add/.babelrc-fixture`
7348 )
7449
7550 // babel-loader doesn't actually hot reloads itself when new .babelrc file is added
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ const args = yargs
3939 ) . trim ( ) ,
4040 type : `string` ,
4141 } )
42+ . option ( `fileSource` , {
43+ type : `string` ,
44+ } )
4245 . option ( `restore` , {
4346 default : false ,
4447 type : `boolean` ,
@@ -64,11 +67,13 @@ async function update() {
6467 let exists = true
6568 if ( ! fs . existsSync ( filePath ) ) {
6669 exists = false
67- await fs . writeFile (
68- filePath ,
69- JSON . parse ( args . fileContent ) . replace ( / \+ n / g, `\n` ) ,
70- `utf8`
71- )
70+ let fileContent
71+ if ( args . fileSource ) {
72+ fileContent = await fs . readFile ( args . fileSource , `utf8` )
73+ } else if ( args . fileContent ) {
74+ fileContent = JSON . parse ( args . fileContent ) . replace ( / \+ n / g, `\n` )
75+ }
76+ await fs . writeFile ( filePath , fileContent , `utf8` )
7277 }
7378 const file = await fs . readFile ( filePath , `utf8` )
7479
Original file line number Diff line number Diff line change 1+ {
2+ "plugins": [
3+ [
4+ "babel-plugin-search-and-replace",
5+ {
6+ "rules": [
7+ {
8+ "search": "babel-rc-test",
9+ "replace": "babel-rc-added",
10+ "searchTemplateStrings": true
11+ }
12+
13+ ]
14+ }
15+ ]
16+ ],
17+ "presets": [
18+ "babel-preset-gatsby"
19+ ]
20+ }
You can’t perform that action at this time.
0 commit comments