2017-08-14 13:30:33 +00:00
|
|
|
import R from 'ramda'
|
|
|
|
|
|
|
|
// This array can't be generated, as the arguments to require.context must be literals :-|
|
|
|
|
let directoryLoaders =
|
|
|
|
[
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
// require.context returns an object which
|
|
|
|
// a) is a function behaving like 'requires', taking a filename and returning a module and
|
|
|
|
// b) has additional properties, some function-valued; keys() returns the files matched
|
|
|
|
// A "module" is simply the contents of a file according to a Webpack loader; this can be JS, JSON, etc.
|
|
|
|
// Thus, this weird loadAll returns an array, each item of which is the contents of each file in a directory
|
|
|
|
let loadAll = directoryLoaderFunction =>
|
|
|
|
directoryLoaderFunction.keys().map(directoryLoaderFunction)
|
|
|
|
|
|
|
|
let directoryLoaderFunction =
|
|
|
|
require.context('./mécanismes', true, /.yaml$/)
|
|
|
|
|
|
|
|
let items =
|
|
|
|
loadAll(directoryLoaderFunction)
|
2017-08-16 11:41:30 +00:00
|
|
|
console.log('items', items)
|
2017-08-14 13:30:33 +00:00
|
|
|
export default items
|