Skip to content

Commit 38c55ca

Browse files
committed
Fetch data source for git dependency installs
1 parent 97d92ee commit 38c55ca

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

bin/ensure_minecraft_data.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,27 @@
33
const fs = require('fs')
44
const { spawnSync } = require('child_process')
55

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'
79

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

Comments
 (0)