@@ -4,16 +4,7 @@ const cwd = process.env.METASCRAPER_CWD || process.cwd()
4
4
const config = require ( 'cosmiconfig' ) ( 'metascraper' ) . load ( cwd )
5
5
const resolveFrom = require ( 'resolve-from' )
6
6
7
- const {
8
- map,
9
- findIndex,
10
- forEach,
11
- chain,
12
- isObject,
13
- isArray,
14
- isString,
15
- get
16
- } = require ( 'lodash' )
7
+ const { map, findIndex, forEach, chain, isObject, isArray, isString, get} = require ( 'lodash' )
17
8
18
9
const DEFAULT_RULES = [
19
10
'metascraper-author' ,
@@ -30,25 +21,22 @@ const DEFAULT_RULES = [
30
21
31
22
const load = rules =>
32
23
chain ( rules )
33
- // merge rules with same props
34
- . reduce ( ( acc , rules ) => {
35
- forEach ( rules , function ( rule , propName ) {
36
- const index = findIndex ( acc , item => item [ propName ] )
37
- if ( index !== - 1 ) {
38
- acc [ index ] [ propName ] = acc [ index ] [ propName ] . concat ( rule )
39
- } else {
40
- acc . push ( { [ propName ] : rule } )
41
- }
24
+ // merge rules with same props
25
+ . reduce ( ( acc , rules ) => {
26
+ forEach ( rules , function ( rule , propName ) {
27
+ const index = findIndex ( acc , item => item [ propName ] )
28
+ if ( index !== - 1 ) acc [ index ] [ propName ] = acc [ index ] [ propName ] . concat ( rule )
29
+ else acc . push ( { [ propName ] : rule } )
30
+ } )
31
+ return acc
32
+ } , [ ] )
33
+ // export an array interface, it's easier to iterate
34
+ . map ( obj => {
35
+ const key = Object . keys ( obj ) [ 0 ]
36
+ const value = obj [ key ]
37
+ return [ key , value ]
42
38
} )
43
- return acc
44
- } , [ ] )
45
- // export an array interface, it's easier to iterate
46
- . map ( obj => {
47
- const key = Object . keys ( obj ) [ 0 ]
48
- const value = obj [ key ]
49
- return [ key , value ]
50
- } )
51
- . value ( )
39
+ . value ( )
52
40
53
41
const autoload = async ( ) => {
54
42
const configFile = await config
0 commit comments