File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ // find-bad-imports
2
+ //
3
+ // uses `deno info --json` to find all imports that are not in our
4
+ // standard format.
5
+
6
+ const entryPoints = [
7
+ "package/src/bld.ts" ,
8
+ "src/quarto.ts" ,
9
+ ] ;
10
+
11
+ let foundBadImport = false ;
12
+
13
+ for ( const entry of entryPoints ) {
14
+ // this only works if you have deno installed!
15
+ const cmd = new Deno . Command ( "deno" , {
16
+ args : [ "info" , "--json" , entry ] ,
17
+ stdout : "piped" ,
18
+ stderr : "piped" ,
19
+ } ) ;
20
+
21
+ const output = cmd . outputSync ( ) ;
22
+
23
+ if ( ! output . success ) {
24
+ console . log ( new TextDecoder ( ) . decode ( output . stderr ) ) ;
25
+ Deno . exit ( 1 ) ;
26
+ }
27
+
28
+ const info = JSON . parse ( new TextDecoder ( ) . decode ( output . stdout ) ) ;
29
+ const modules = info . modules || [ ] ;
30
+ for ( const module of modules ) {
31
+ if ( ( module . local || "" ) . match ( "src/vendor" ) ) {
32
+ // don't analyze vendor code
33
+ continue ;
34
+ }
35
+ for ( const dep of module . dependencies || [ ] ) {
36
+ const code = dep . code || { } ;
37
+ if ( ( ( code . specifier || "" ) as string ) . match ( "src/vendor" ) ) {
38
+ foundBadImport = true ;
39
+ console . log (
40
+ `Bad import in ${ module . local } :${ code . span . start . line + 1 } (${
41
+ code . span . start . character + 1
42
+ } --${ code . span . end . character + 1 } )`,
43
+ ) ;
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ if ( foundBadImport ) {
50
+ Deno . exit ( 1 ) ;
51
+ }
You can’t perform that action at this time.
0 commit comments