File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import moduleVisitor from 'eslint-module-utils/moduleVisitor'
7
7
import importType from '../core/importType'
8
8
import docsUrl from '../docsUrl'
9
9
10
+ const depFieldCache = new Map ( )
11
+
10
12
function hasKeys ( obj = { } ) {
11
13
return Object . keys ( obj ) . length > 0
12
14
}
@@ -49,9 +51,14 @@ function getDependencies(context, packageDir) {
49
51
if ( paths . length > 0 ) {
50
52
// use rule config to find package.json
51
53
paths . forEach ( dir => {
52
- const _packageContent = extractDepFields (
53
- JSON . parse ( fs . readFileSync ( path . join ( dir , 'package.json' ) , 'utf8' ) )
54
- )
54
+ const packageJsonPath = path . join ( dir , 'package.json' )
55
+ if ( ! depFieldCache . has ( packageJsonPath ) ) {
56
+ const depFields = extractDepFields (
57
+ JSON . parse ( fs . readFileSync ( packageJsonPath , 'utf8' ) )
58
+ )
59
+ depFieldCache . set ( packageJsonPath , depFields )
60
+ }
61
+ const _packageContent = depFieldCache . get ( packageJsonPath )
55
62
Object . keys ( packageContent ) . forEach ( depsKey =>
56
63
Object . assign ( packageContent [ depsKey ] , _packageContent [ depsKey ] )
57
64
)
You can’t perform that action at this time.
0 commit comments