UNPKG

520 BJavaScriptView Raw
1'use strict';
2
3const fs = require('fs');
4const path = require('path');
5
6const loadCollections = (sagasDirectory) => {
7 const sagas = {};
8
9 fs.readdirSync(sagasDirectory).forEach((sagaName) => {
10 const sagaFile = path.join(sagasDirectory, sagaName);
11
12
13 if (!fs.statSync(sagaFile).isFile() || path.extname(sagaFile) !== '.js')
14 return;
15
16 sagas[path.basename(sagaName, '.js')] = {
17 path: sagaFile,
18 };
19 });
20
21 return sagas;
22};
23
24module.exports = (sagasDirectory, options) => loadCollections(sagasDirectory, options);