-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (37 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* Finds and returns entry point files in a custom folder
*
* @since 08.03.2017
* @type Module
* @author Sergej Müller, superReal GmbH
*/
/**
* Required modules
*/
const glob = require( 'glob' )
const path = require( 'path' )
/**
* Finds and returns entry point files in a custom folder
*
* @since 08.03.2017
* @access public
*
* @param string rootPath Root path of glob path [required]
* @param string globPath Glob path for entry points [required]
* @param string entryExt Extension of entry point files [optional]
*
* @return object entries Object with collected entry points
*/
module.exports = ( ( rootPath, globPath, entryExt = '.entry.js' ) => {
const fullPath = path.join( rootPath, globPath )
const globFiles = glob.sync( fullPath )
let entries = {}
let entry
let name
globFiles.forEach( globFile => {
entry = path.relative( rootPath, globFile )
name = entry.replace( entryExt, '' )
entries[ name ] = entry
} )
return entries
} )