@@ -62,7 +62,7 @@ const cli = yargs
62
62
. help ( )
63
63
. version ( ) ;
64
64
65
- function main ( flags ) {
65
+ async function main ( flags ) {
66
66
if ( ! Proxy ) {
67
67
console
68
68
. warn ( 'Skipping pkg-check, detected missing Proxy support' )
@@ -73,59 +73,53 @@ function main(flags) {
73
73
const skipImport =
74
74
typeof flags . skipImport === 'boolean' ? flags . skipImport : false ;
75
75
76
- return readPkg ( { cwd} ) . then ( pkg => {
77
- return getTarballFiles ( cwd , { write : ! skipImport } ) . then ( tarball => {
78
- return getPackageFiles ( cwd ) . then ( pkgFiles => {
79
- let problems = [ ] ;
80
-
81
- if ( ! flags . skipBin ) {
82
- problems = problems . concat (
83
- pkgFiles . bin
84
- . filter ( binFile => tarball . files . indexOf ( binFile ) === - 1 )
85
- . map ( binFile => ( {
86
- type : 'bin' ,
87
- file : binFile ,
88
- message : `Required bin file ${ binFile } not found for ${
89
- pkg . name
90
- } `
91
- } ) )
92
- ) ;
93
- }
94
-
95
- if ( ! flags . skipMain && tarball . files . indexOf ( pkgFiles . main ) === - 1 ) {
96
- problems . push ( {
97
- type : 'main' ,
98
- file : pkgFiles . main ,
99
- message : `Required main file ${ pkgFiles . main } not found for ${
100
- pkg . name
101
- } `
102
- } ) ;
103
- }
104
-
105
- if ( ! flags . skipImport && ! flags . skipMain ) {
106
- const importable = fileImportable (
107
- path . join ( tarball . dirname , pkgFiles . main )
108
- ) ;
109
- if ( ! importable [ 1 ] ) {
110
- problems . push ( {
111
- type : 'import' ,
112
- file : pkgFiles . main ,
113
- message : `Error while importing ${ pkgFiles . main } : ${
114
- importable [ 0 ] . message
115
- } `
116
- } ) ;
117
- }
118
- }
119
-
120
- return {
121
- pkg : pkg ,
122
- pkgFiles : pkgFiles ,
123
- files : tarball . files ,
124
- problems : problems
125
- } ;
126
- } ) ;
76
+ const pkg = await readPkg ( { cwd} ) ;
77
+ const tarball = await getTarballFiles ( cwd , { write : ! skipImport } ) ;
78
+ const pkgFiles = await getPackageFiles ( cwd ) ;
79
+
80
+ let problems = [ ] ;
81
+
82
+ if ( ! flags . skipBin ) {
83
+ problems = problems . concat (
84
+ pkgFiles . bin
85
+ . filter ( binFile => tarball . files . indexOf ( binFile ) === - 1 )
86
+ . map ( binFile => ( {
87
+ type : 'bin' ,
88
+ file : binFile ,
89
+ message : `Required bin file ${ binFile } not found for ${ pkg . name } `
90
+ } ) )
91
+ ) ;
92
+ }
93
+
94
+ if ( ! flags . skipMain && tarball . files . indexOf ( pkgFiles . main ) === - 1 ) {
95
+ problems . push ( {
96
+ type : 'main' ,
97
+ file : pkgFiles . main ,
98
+ message : `Required main file ${ pkgFiles . main } not found for ${ pkg . name } `
127
99
} ) ;
128
- } ) ;
100
+ }
101
+
102
+ if ( ! flags . skipImport && ! flags . skipMain ) {
103
+ const importable = fileImportable (
104
+ path . join ( tarball . dirname , pkgFiles . main )
105
+ ) ;
106
+ if ( ! importable [ 1 ] ) {
107
+ problems . push ( {
108
+ type : 'import' ,
109
+ file : pkgFiles . main ,
110
+ message : `Error while importing ${ pkgFiles . main } : ${
111
+ importable [ 0 ] . message
112
+ } `
113
+ } ) ;
114
+ }
115
+ }
116
+
117
+ return {
118
+ pkg : pkg ,
119
+ pkgFiles : pkgFiles ,
120
+ files : tarball . files ,
121
+ problems : problems
122
+ } ;
129
123
}
130
124
131
125
main ( cli . argv )
0 commit comments