|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | const path = require('path'); |
4 | | -const { existsSync, readdirSync, statSync } = require('fs'); |
| 4 | +const { existsSync, mkdirSync, readdirSync, statSync } = require('fs'); |
5 | 5 | const { spawnSync } = require('child_process'); |
6 | 6 | const { ensurePortableGit } = require('./setup-mingit.js'); |
7 | 7 | const { ensurePortablePythonRuntime, checkRuntimeHealth } = require('./setup-python-runtime.js'); |
@@ -29,6 +29,40 @@ function findPackagedBash(appOutDir) { |
29 | 29 | return null; |
30 | 30 | } |
31 | 31 |
|
| 32 | +function verifyPackagedPortableGitRuntimeDirs(appOutDir) { |
| 33 | + const requiredDirs = [ |
| 34 | + path.join(appOutDir, 'resources', 'mingit', 'dev', 'shm'), |
| 35 | + path.join(appOutDir, 'resources', 'mingit', 'dev', 'mqueue'), |
| 36 | + ]; |
| 37 | + const createdDirs = []; |
| 38 | + |
| 39 | + for (const dir of requiredDirs) { |
| 40 | + if (existsSync(dir)) continue; |
| 41 | + mkdirSync(dir, { recursive: true }); |
| 42 | + createdDirs.push(dir); |
| 43 | + } |
| 44 | + |
| 45 | + const missingDirs = requiredDirs.filter((dir) => !existsSync(dir)); |
| 46 | + if (missingDirs.length > 0) { |
| 47 | + throw new Error( |
| 48 | + 'Windows package is missing required PortableGit runtime directories. ' |
| 49 | + + `Missing: ${missingDirs.join(', ')}` |
| 50 | + ); |
| 51 | + } |
| 52 | + |
| 53 | + if (createdDirs.length > 0) { |
| 54 | + console.log( |
| 55 | + '[electron-builder-hooks] Created missing PortableGit runtime directories: ' |
| 56 | + + createdDirs.join(', ') |
| 57 | + ); |
| 58 | + } |
| 59 | + |
| 60 | + console.log( |
| 61 | + '[electron-builder-hooks] Verified PortableGit runtime directories: ' |
| 62 | + + requiredDirs.join(', ') |
| 63 | + ); |
| 64 | +} |
| 65 | + |
32 | 66 | function findPackagedPythonExecutable(appOutDir) { |
33 | 67 | const candidates = [ |
34 | 68 | path.join(appOutDir, 'resources', 'python-win', 'python.exe'), |
@@ -380,6 +414,7 @@ async function afterPack(context) { |
380 | 414 | } |
381 | 415 |
|
382 | 416 | console.log(`[electron-builder-hooks] Verified bundled PortableGit: ${bashPath}`); |
| 417 | + verifyPackagedPortableGitRuntimeDirs(context.appOutDir); |
383 | 418 |
|
384 | 419 | const pythonExe = findPackagedPythonExecutable(context.appOutDir); |
385 | 420 | if (!pythonExe) { |
|
0 commit comments