1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
1
18
import glob from 'glob' ;
2
19
import { existsSync } from 'fs' ;
3
20
import { resolve } from 'path' ;
@@ -29,10 +46,15 @@ function getPaths(): Promise<string[]> {
29
46
if ( err ) reject ( err ) ;
30
47
resolve ( paths ) ;
31
48
} ) ;
32
- } )
49
+ } ) ;
33
50
}
34
51
35
- function checkExports ( pkgName : string , pkgRoot : string , path : string = '' , exports : Record < string , any > ) {
52
+ function checkExports (
53
+ pkgName : string ,
54
+ pkgRoot : string ,
55
+ path : string = '' ,
56
+ exports : Record < string , any >
57
+ ) {
36
58
for ( const key in exports ) {
37
59
if ( typeof exports [ key ] === 'string' ) {
38
60
const filePath = resolve ( pkgRoot , exports [ key ] ) ;
@@ -47,7 +69,12 @@ function checkExports(pkgName: string, pkgRoot: string, path: string = '', expor
47
69
}
48
70
results . push ( result ) ;
49
71
} else {
50
- checkExports ( pkgName , pkgRoot , path ? `${ path } [${ key } ]` : `[${ key } ]` , exports [ key ] ) ;
72
+ checkExports (
73
+ pkgName ,
74
+ pkgRoot ,
75
+ path ? `${ path } [${ key } ]` : `[${ key } ]` ,
76
+ exports [ key ]
77
+ ) ;
51
78
}
52
79
}
53
80
}
@@ -84,8 +111,10 @@ async function main() {
84
111
for ( const result of results ) {
85
112
if ( ! result . found ) {
86
113
missingPaths = true ;
87
- console . log ( `${ result . packageName } : Field "${ result . fieldPath } " ` +
88
- `points to ${ result . filePath } which is not found.` ) ;
114
+ console . log (
115
+ `${ result . packageName } : Field "${ result . fieldPath } " ` +
116
+ `points to ${ result . filePath } which is not found.`
117
+ ) ;
89
118
}
90
119
}
91
120
@@ -94,4 +123,4 @@ async function main() {
94
123
}
95
124
}
96
125
97
- main ( ) ;
126
+ main ( ) ;
0 commit comments