UNPKG

@cloud-copilot/iam-collect

Version:

Collect IAM information from AWS Accounts

49 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadConfigFiles = loadConfigFiles; exports.loadConfigFile = loadConfigFile; const fs_1 = require("fs"); const jsonc_parser_1 = require("jsonc-parser"); const path_1 = require("path"); /** * Gets the current directory the process is running in * * @returns the current directory */ function getCurrentDirectory() { return process.cwd(); } /** * Load config files from the given paths * * @param paths the paths to the config files * @returns the loaded config files */ function loadConfigFiles(paths) { return paths.map(loadConfigFile); } /** * Load a config file from the given path * * @param path the path to the config file * @returns the loaded config file */ function loadConfigFile(path) { const absPath = getAbsolutePath(path); const contents = (0, fs_1.readFileSync)(absPath, 'utf-8'); const parsed = (0, jsonc_parser_1.parse)(contents); return parsed; } /** * Get the absolute path to a configuration file * * @param path - The path to the configuration file * @returns the absolute path to the configuration file */ function getAbsolutePath(path) { if (path.startsWith('.')) { return (0, path_1.resolve)(getCurrentDirectory(), path); } return (0, path_1.resolve)(path); } //# sourceMappingURL=configFile.js.map