1
1
#!/usr/bin/env node
2
2
'use strict' ;
3
3
4
- const { createWriteStream, mkdir} = require ( 'fs' ) ;
4
+ const { createWriteStream, promises : { mkdir} } = require ( 'fs' ) ;
5
5
const { dirname, extname, join, resolve : resolvePath } = require ( 'path' ) ;
6
+ const { once} = require ( 'events' ) ;
6
7
const { promisify} = require ( 'util' ) ;
7
8
const { spawn} = require ( 'child_process' ) ;
8
9
@@ -100,41 +101,18 @@ const codecovBashPath = process.platform === 'win32' ? join(cwd, 'coverage', Mat
100
101
}
101
102
102
103
const [ code , codecovBash ] = await Promise . all ( [
103
- ( async ( ) => {
104
- /*
105
- On Node.js >= 11.3.0, const {once} = require('events') is available
106
- https://nodejs.org/api/events.html#events_events_once_emitter_name
107
-
108
- return (await once(spawn(...await prepareArgs, {
109
- cwd,
110
- stdio: 'inherit',
111
- timeout
112
- }), 'exit'))[0];
113
- */
114
-
115
- const args = await prepareArgs ;
116
-
117
- return new Promise ( ( resolve , reject ) => {
118
- spawn ( ...args , {
119
- cwd,
120
- stdio : 'inherit' ,
121
- timeout
122
- } )
123
- . once ( 'error' , reject )
124
- . once ( 'exit' , resolve ) ;
125
- } ) ;
126
- } ) ( ) ,
104
+ ( async ( ) => ( await once ( spawn ( ...await prepareArgs , {
105
+ cwd,
106
+ stdio : 'inherit' ,
107
+ timeout
108
+ } ) , 'exit' ) ) [ 0 ] ) ( ) ,
127
109
( async ( ) => {
128
110
try {
129
111
// The default shell of Travis CI Windows build is Git BASH
130
112
if ( ! ( process . platform === 'win32' && isTravisCi ) ) {
131
113
await Promise . all ( [ promisifiedWhich ( 'bash' ) , promisifiedWhich ( 'git' ) ] ) ;
132
114
}
133
115
} catch {
134
- /*
135
- On Node.js >= 11.3.0, const {once} = require('events') is available
136
- https://nodejs.org/api/events.html#events_events_once_emitter_name
137
-
138
116
await once ( spawn ( 'npm' , [
139
117
'install' ,
140
118
'--no-package-lock' ,
@@ -145,19 +123,8 @@ const codecovBashPath = process.platform === 'win32' ? join(cwd, 'coverage', Mat
145
123
shell : process . platform === 'win32' ,
146
124
timeout
147
125
} ) , 'exit' ) ;
148
- */
149
126
150
- return new Promise ( resolve => spawn ( 'npm' , [
151
- 'install' ,
152
- '--no-audit' ,
153
- '--no-package-lock' ,
154
- '--no-save' ,
155
- 'codecov@3'
156
- ] , {
157
- cwd,
158
- shell : process . platform === 'win32' ,
159
- timeout
160
- } ) . once ( 'exit' , ( ) => resolve ( null ) ) ) ;
127
+ return null ;
161
128
}
162
129
163
130
const { connect} = require ( 'http2' ) ;
@@ -171,7 +138,7 @@ const codecovBashPath = process.platform === 'win32' ? join(cwd, 'coverage', Mat
171
138
request . end ( ) ;
172
139
173
140
if ( codecovBashPath ) {
174
- await promisify ( mkdir ) ( dirname ( codecovBashPath ) , { recursive : true } ) ;
141
+ await mkdir ( dirname ( codecovBashPath ) , { recursive : true } ) ;
175
142
}
176
143
177
144
await promisify ( pipeline ) ( [
0 commit comments