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+
118import glob from 'glob' ;
219import { existsSync } from 'fs' ;
320import { resolve } from 'path' ;
@@ -29,10 +46,15 @@ function getPaths(): Promise<string[]> {
2946 if ( err ) reject ( err ) ;
3047 resolve ( paths ) ;
3148 } ) ;
32- } )
49+ } ) ;
3350}
3451
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+ ) {
3658 for ( const key in exports ) {
3759 if ( typeof exports [ key ] === 'string' ) {
3860 const filePath = resolve ( pkgRoot , exports [ key ] ) ;
@@ -47,7 +69,12 @@ function checkExports(pkgName: string, pkgRoot: string, path: string = '', expor
4769 }
4870 results . push ( result ) ;
4971 } 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+ ) ;
5178 }
5279 }
5380}
@@ -84,8 +111,10 @@ async function main() {
84111 for ( const result of results ) {
85112 if ( ! result . found ) {
86113 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+ ) ;
89118 }
90119 }
91120
@@ -94,4 +123,4 @@ async function main() {
94123 }
95124}
96125
97- main ( ) ;
126+ main ( ) ;
0 commit comments