UNPKG

dop-stick

Version:

Source control tooling for versionable-upgradeable smart contracts

37 lines 1.55 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadConfig = void 0; const path_1 = __importDefault(require("path")); const fs_1 = __importDefault(require("fs")); function loadConfig(options = { requireUpgrades: true }) { var _a; const configPath = path_1.default.join(process.cwd(), 'dop-stick.config.json'); if (!fs_1.default.existsSync(configPath)) { throw new Error('dop-stick.config.json not found in project root'); } try { const configContent = fs_1.default.readFileSync(configPath, 'utf8'); const config = JSON.parse(configContent); if (options.requireUpgrades) { if (!((_a = config.paths) === null || _a === void 0 ? void 0 : _a.upgrades)) { throw new Error('Missing required path: paths.upgrades in dop-stick.config.json'); } const upgradesPath = path_1.default.join(process.cwd(), config.paths.upgrades); if (!fs_1.default.existsSync(upgradesPath)) { throw new Error(`upgrades.json not found at specified path: ${config.paths.upgrades}`); } } return config; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to load config: ${error.message}`); } throw error; } } exports.loadConfig = loadConfig; //# sourceMappingURL=config.js.map