@cloud-copilot/iam-data
Version:
20 lines • 712 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.readRelativeFile = readRelativeFile;
const promises_1 = require("fs/promises");
const path_1 = require("path");
let root = (0, path_1.join)(__dirname, '..', '..');
if (__dirname.endsWith('src')) {
root = (0, path_1.join)(__dirname, '..');
}
/**
* Get a data file from the data directory in CommonJS
*
* @param file the path to the file to retrieve data for.
* @returns the data from the file
*/
async function readRelativeFile(pathParts) {
const contents = await (0, promises_1.readFile)((0, path_1.join)(root, ...pathParts), 'utf8');
return JSON.parse(contents);
}
//# sourceMappingURL=readRelativeFile.js.map