2023-08-15 08:53:29 +00:00
|
|
|
const fs = require( 'fs' );
|
|
|
|
const path = require( 'path' );
|
|
|
|
|
2023-08-17 03:51:16 +00:00
|
|
|
/**
|
|
|
|
* @param {string} blocksDir
|
|
|
|
* @returns {any[][]}
|
|
|
|
*/
|
2023-08-15 08:53:29 +00:00
|
|
|
const readContextBlocksFromJsonFiles = ( blocksDir ) => {
|
|
|
|
const jsonsDir = path.resolve( blocksDir );
|
|
|
|
const jsons = fs.readdirSync( jsonsDir );
|
|
|
|
|
|
|
|
let contextBlocks = [];
|
|
|
|
|
|
|
|
for ( const json of jsons ) {
|
|
|
|
const jsonPath = path.resolve( jsonsDir, json );
|
|
|
|
const contextBlock = require( jsonPath );
|
|
|
|
|
|
|
|
contextBlocks.push( contextBlock );
|
|
|
|
}
|
|
|
|
|
|
|
|
return contextBlocks;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
readContextBlocksFromJsonFiles,
|
|
|
|
};
|