|
3 | 3 | const fs = require('fs') |
4 | 4 | const { spawnSync } = require('child_process') |
5 | 5 |
|
6 | | -if (fs.existsSync('minecraft-data/data/dataPaths.json')) process.exit(0) |
| 6 | +const dataPaths = 'minecraft-data/data/dataPaths.json' |
| 7 | +const dataRepo = 'https://github.com/mneuhaus/minecraft-data.git' |
| 8 | +const dataBranch = 'pc_26_1_2' |
7 | 9 |
|
8 | | -const result = spawnSync('git', ['submodule', 'update', '--init', '--recursive'], { stdio: 'inherit' }) |
9 | | -if (result.status !== 0) process.exit(result.status || 1) |
| 10 | +if (fs.existsSync(dataPaths)) process.exit(0) |
| 11 | + |
| 12 | +if (fs.existsSync('.git')) { |
| 13 | + const result = spawnSync('git', ['submodule', 'update', '--init', '--recursive'], { stdio: 'inherit' }) |
| 14 | + if (result.status !== 0) process.exit(result.status || 1) |
| 15 | + if (fs.existsSync(dataPaths)) process.exit(0) |
| 16 | +} |
| 17 | + |
| 18 | +fs.rmSync('minecraft-data', { recursive: true, force: true }) |
| 19 | + |
| 20 | +const clone = spawnSync('git', ['clone', '--depth', '1', '--filter=blob:none', '--sparse', '--branch', dataBranch, dataRepo, 'minecraft-data'], { stdio: 'inherit' }) |
| 21 | +if (clone.status !== 0) process.exit(clone.status || 1) |
| 22 | + |
| 23 | +const sparse = spawnSync('git', ['-C', 'minecraft-data', 'sparse-checkout', 'set', 'data'], { stdio: 'inherit' }) |
| 24 | +if (sparse.status !== 0) process.exit(sparse.status || 1) |
| 25 | + |
| 26 | +if (!fs.existsSync(dataPaths)) { |
| 27 | + console.error(`Could not load ${dataPaths}`) |
| 28 | + process.exit(1) |
| 29 | +} |
0 commit comments