mirror of
https://github.com/bmad-code-org/BMAD-METHOD.git
synced 2026-09-19 08:11:52 +08:00
a6d075bd0b
fs-extra routes all operations through graceful-fs, which globally monkey-patches node:fs with a deferred retry queue. During multi-module installs (~500+ file ops), retried unlink operations from one module's remove phase can fire after the next module's copy phase has written files, silently deleting them non-deterministically. Replace fs-extra with a thin fs-native.js wrapper over node:fs/promises and node:fs. All 21 consumers now use native APIs with no global monkey-patching, eliminating the retry-queue race condition entirely. Closes #1779
38 lines
897 B
JavaScript
38 lines
897 B
JavaScript
const fs = require('../fs-native');
|
|
const path = require('node:path');
|
|
const yaml = require('yaml');
|
|
|
|
const PLATFORM_CODES_PATH = path.join(__dirname, 'platform-codes.yaml');
|
|
|
|
let _cachedPlatformCodes = null;
|
|
|
|
/**
|
|
* Load the platform codes configuration from YAML
|
|
* @returns {Object} Platform codes configuration
|
|
*/
|
|
async function loadPlatformCodes() {
|
|
if (_cachedPlatformCodes) {
|
|
return _cachedPlatformCodes;
|
|
}
|
|
|
|
if (!(await fs.pathExists(PLATFORM_CODES_PATH))) {
|
|
throw new Error(`Platform codes configuration not found at: ${PLATFORM_CODES_PATH}`);
|
|
}
|
|
|
|
const content = await fs.readFile(PLATFORM_CODES_PATH, 'utf8');
|
|
_cachedPlatformCodes = yaml.parse(content);
|
|
return _cachedPlatformCodes;
|
|
}
|
|
|
|
/**
|
|
* Clear the cached platform codes (useful for testing)
|
|
*/
|
|
function clearCache() {
|
|
_cachedPlatformCodes = null;
|
|
}
|
|
|
|
module.exports = {
|
|
loadPlatformCodes,
|
|
clearCache,
|
|
};
|