Skip to content

Commit ca69649

Browse files
committed
maybe this command will work in circle?
1 parent 1076b1f commit ca69649

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

e2e-tests/development-runtime/cypress/integration/functionality/babelrc.js

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const 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

e2e-tests/development-runtime/scripts/update.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff 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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

0 commit comments

Comments
 (0)