-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathaccept-changes.cjs
36 lines (32 loc) · 1.31 KB
/
accept-changes.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require('fs')
const prettier = require('prettier')
function copyHashes(failHashFile, refHashFile) {
let failHashData
try {
failHashData = JSON.parse(fs.readFileSync(failHashFile))
} catch (error) {
return
}
const refHashData = JSON.parse(fs.readFileSync(refHashFile))
for (const testFilename in failHashData.test) {
if (!refHashData.test[testFilename]) {
refHashData.test[testFilename] = {
refs: [failHashData.test[testFilename].refs[0]]
}
} else if (refHashData.test[testFilename].refs[0] !== '')
refHashData.test[testFilename].refs[0] = failHashData.test[testFilename].refs[0]
}
const formattedRefHashDataReady = prettier.format(JSON.stringify(refHashData, null, '\t'), {
parser: 'json',
tabWidth: 4,
useTabs: true
})
formattedRefHashDataReady.then((formattedRefHashData) => {
fs.writeFileSync(refHashFile, formattedRefHashData)
})
}
copyHashes('test_report/results/test_cases/test_cases.json', 'test_cases/test_cases.json')
copyHashes('test_report/results/tests/style_tests/style_tests.json', 'tests/style_tests.json')
copyHashes('test_report/results/tests/features/features.json', 'tests/features.json')
copyHashes('test_report/results/tests/fixes/fixes.json', 'tests/fixes.json')
copyHashes('test_report/results/tests/config_tests/config_tests.json', 'tests/config_tests.json')