-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfix-xwing-data.js
More file actions
32 lines (26 loc) · 806 Bytes
/
fix-xwing-data.js
File metadata and controls
32 lines (26 loc) · 806 Bytes
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
import fs from 'fs'
const fileRoot = 'xwing-data/data/'
const dataFiles = [
'conditions.js',
'damage-deck-core.js',
'damage-deck-core-tfa.js',
'damage-deck-rebel-transport.js',
'pilots.js',
'reference-cards.js',
'ships.js',
'sources.js',
'upgrades.js'
]
const fixData = (fileName) => {
const originalFileData = fs.readFileSync(`${fileRoot}${fileName}`)
const newFileData = `module.exports = ${originalFileData}`
const constIndex = originalFileData.indexOf(newFileData)
if (constIndex === -1) {
console.log(`${fileName} is being converted...`)
fs.writeFileSync(`${fileRoot}${fileName}`, newFileData)
console.log(`${fileName} converted!`)
} else {
console.warn(`${fileName} has already been converted, skipping...`)
}
}
dataFiles.forEach(fixData)