Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions bin/ensure_minecraft_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env node

const fs = require('fs')
const { spawnSync } = require('child_process')

const dataPaths = 'minecraft-data/data/dataPaths.json'
const dataRepo = 'https://github.com/mneuhaus/minecraft-data.git'
const dataBranch = 'pc_26_1_2'

if (fs.existsSync(dataPaths)) process.exit(0)

if (fs.existsSync('.git')) {
const result = spawnSync('git', ['submodule', 'update', '--init', '--recursive'], { stdio: 'inherit' })
if (result.status === 0 && fs.existsSync(dataPaths)) process.exit(0)
}

fs.rmSync('minecraft-data', { recursive: true, force: true })

const clone = spawnSync('git', ['clone', '--depth', '1', '--filter=blob:none', '--sparse', '--branch', dataBranch, dataRepo, 'minecraft-data'], { stdio: 'inherit' })
if (clone.status !== 0) process.exit(clone.status || 1)

const sparse = spawnSync('git', ['-C', 'minecraft-data', 'sparse-checkout', 'set', 'data', 'schemas'], { stdio: 'inherit' })
if (sparse.status !== 0) process.exit(sparse.status || 1)

if (!fs.existsSync(dataPaths)) {
console.error(`Could not load ${dataPaths}`)
process.exit(1)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test:types": "tsc typings/test-typings && node typings/test-typings.js",
"test": "npm run generate:types && npm run generate:data && npm run lint && npm run test:types && mocha",
"lint": "standard",
"prepare": "npm run generate:data && npm run generate:types",
"prepare": "node ./bin/ensure_minecraft_data.js && npm run generate:data && npm run generate:types",
"fix": "standard --fix"
},
"standard": {
Expand Down
Loading