| 28 | } |
| 29 | |
| 30 | async function saveLevel (level, options) { |
| 31 | const fileName = `level-${level.parametersKey}.json` |
| 32 | |
| 33 | // Make the levels output directory |
| 34 | const levelsDir = path.join(PWD, 'levels') |
| 35 | if (!fs.existsSync(levelsDir)) { |
| 36 | fs.mkdirSync(levelsDir) |
| 37 | } |
| 38 | |
| 39 | // Write the level to a file |
| 40 | const levelPath = path.join(levelsDir, fileName) |
| 41 | fs.writeFileSync(levelPath, JSON.stringify(level, null, 2)) |
| 42 | console.log(`Wrote level to ${levelPath}`) |
| 43 | |
| 44 | if (!options.dry) { |
| 45 | // Write the level to the database |
| 46 | // TODO |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | function parseOptions () { |
| 51 | console.log() |