MCPcopy Index your code
hub / github.com/codecombat/codecombat / saveLevel

Function saveLevel

scripts/generateLevels.js:30–48  ·  view source on GitHub ↗
(level, options)

Source from the content-addressed store, hash-verified

28}
29
30async 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
50function parseOptions () {
51 console.log()

Callers 1

mainFunction · 0.85

Calls 2

logMethod · 0.80
stringifyMethod · 0.45

Tested by

no test coverage detected