UNPKG

@dethcrypto/eth-sdk

Version:

🛠 Generate type-safe, lightweight SDK for your Ethereum smart contracts

23 lines • 988 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findConfigFile = void 0; const path_1 = require("path"); const CONFIG_EXTENSIONS = ['.js', '.json', '.cjs', '.ts']; const CONFIG_FILENAMES = ['config', 'eth-sdk.config'].flatMap((name) => CONFIG_EXTENSIONS.map((ext) => `${name}${ext}`)); /** * @param args - arguments passed to the CLI * @param fs - file system fasade * @returns path to config file */ function findConfigFile(args, fs) { const existingConfigs = CONFIG_FILENAMES.map((fn) => (0, path_1.join)(args.workingDirPath, fn)).filter(fs.exists); if (existingConfigs.length === 0) { throw new Error(`Couldn't find a config file. Create one of ${CONFIG_FILENAMES.join(', ')} in ${args.workingDirPath}`); } if (existingConfigs.length > 1) { throw new Error(`Found too many config files!`); } return existingConfigs[0]; } exports.findConfigFile = findConfigFile; //# sourceMappingURL=findConfigFile.js.map