@moonsong-labs/moonwall-cli
Version:
Testing framework for the Moon family of projects
33 lines (31 loc) • 877 B
JavaScript
// src/lib/configReader.ts
import "@moonbeam-network/api-augment";
import fs from "fs/promises";
import path from "path";
async function loadConfig(path2) {
if (!await fs.access(path2).then(() => true).catch(() => false)) {
throw new Error(`Moonwall Config file ${path2} cannot be found`);
}
const file = await fs.readFile(path2, { encoding: "utf-8" });
const json = JSON.parse(file);
return json;
}
async function importConfig(configPath) {
return await import(configPath);
}
async function importJsonConfig() {
const filePath = path.join(process.cwd(), "moonwall.config.json");
try {
const file = await fs.readFile(filePath, "utf8");
const json = JSON.parse(file);
return json;
} catch (e) {
console.error(e);
throw new Error(`Error import config at ${filePath}`);
}
}
export {
loadConfig,
importConfig,
importJsonConfig
};