File tree 3 files changed +5
-16
lines changed
3 files changed +5
-16
lines changed Original file line number Diff line number Diff line change 1
1
language : node_js
2
2
node_js :
3
- - ' 8 '
3
+ - ' 14 '
4
4
git :
5
5
submodules : false
6
6
before_script :
Original file line number Diff line number Diff line change 1
1
import * as fs from "fs" ;
2
2
import * as path from "path" ;
3
3
import * as yauzl from "yauzl" ;
4
- import * as util from "util" ;
5
4
import * as shelljs from "shelljs" ;
6
5
7
- const access = util . promisify ( fs . access ) ;
8
- const mkdir = util . promisify ( fs . mkdir ) ;
9
-
10
6
export class FileSystem {
11
7
public exists ( filePath : string ) : boolean {
12
8
return fs . existsSync ( path . resolve ( filePath ) ) ;
@@ -66,12 +62,5 @@ export class FileSystem {
66
62
}
67
63
68
64
function createParentDirsIfNeeded ( filePath : string ) {
69
- const dirs = path . dirname ( filePath ) . split ( path . sep ) ;
70
- return dirs . reduce ( ( p , dir ) => p . then ( parent => {
71
- const current = `${ parent } ${ path . sep } ${ dir } ` ;
72
-
73
- return access ( current )
74
- . catch ( e => mkdir ( current ) )
75
- . then ( ( ) => current ) ;
76
- } ) , Promise . resolve ( '' ) ) ;
65
+ return fs . promises . mkdir ( path . dirname ( filePath ) , { recursive : true } ) ;
77
66
}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ describe('FileSystem', () => {
18
18
] . join ( '' ) ;
19
19
const tmpDir = `${ tmpdir ( ) } /${ datetime } ` ;
20
20
const testFilePath = `${ __dirname } /example.zip` ;
21
- const filesThatNeedToExtsit = [
21
+ const filesThatNeedToExist = [
22
22
`${ tmpDir } /test/android-local-build-requirements.ts` ,
23
23
`${ tmpDir } /test/android-tools-info.ts` ,
24
24
`${ tmpDir } /test/ios-local-build-requirements.ts` ,
@@ -27,11 +27,11 @@ describe('FileSystem', () => {
27
27
] ;
28
28
29
29
it ( 'should extract in example zip archive in tmp folder' , done => {
30
- const fs = new FileSystem ( ) ;
30
+ const fs = new FileSystem ( ) ;
31
31
32
32
fs . extractZip ( testFilePath , tmpDir )
33
33
. then ( ( ) => {
34
- const allExists = filesThatNeedToExtsit
34
+ const allExists = filesThatNeedToExist
35
35
. map ( fs . exists )
36
36
. reduce ( ( acc , r ) => acc && r , true ) ;
37
37
You can’t perform that action at this time.
0 commit comments