File tree Expand file tree Collapse file tree 3 files changed +5
-16
lines changed
Expand file tree Collapse file tree 3 files changed +5
-16
lines changed Original file line number Diff line number Diff line change 11language : node_js
22node_js :
3- - ' 8 '
3+ - ' 14 '
44git :
55 submodules : false
66before_script :
Original file line number Diff line number Diff line change 11import * as fs from "fs" ;
22import * as path from "path" ;
33import * as yauzl from "yauzl" ;
4- import * as util from "util" ;
54import * as shelljs from "shelljs" ;
65
7- const access = util . promisify ( fs . access ) ;
8- const mkdir = util . promisify ( fs . mkdir ) ;
9-
106export class FileSystem {
117 public exists ( filePath : string ) : boolean {
128 return fs . existsSync ( path . resolve ( filePath ) ) ;
@@ -66,12 +62,5 @@ export class FileSystem {
6662}
6763
6864function 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 } ) ;
7766}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ describe('FileSystem', () => {
1818 ] . join ( '' ) ;
1919 const tmpDir = `${ tmpdir ( ) } /${ datetime } ` ;
2020 const testFilePath = `${ __dirname } /example.zip` ;
21- const filesThatNeedToExtsit = [
21+ const filesThatNeedToExist = [
2222 `${ tmpDir } /test/android-local-build-requirements.ts` ,
2323 `${ tmpDir } /test/android-tools-info.ts` ,
2424 `${ tmpDir } /test/ios-local-build-requirements.ts` ,
@@ -27,11 +27,11 @@ describe('FileSystem', () => {
2727 ] ;
2828
2929 it ( 'should extract in example zip archive in tmp folder' , done => {
30- const fs = new FileSystem ( ) ;
30+ const fs = new FileSystem ( ) ;
3131
3232 fs . extractZip ( testFilePath , tmpDir )
3333 . then ( ( ) => {
34- const allExists = filesThatNeedToExtsit
34+ const allExists = filesThatNeedToExist
3535 . map ( fs . exists )
3636 . reduce ( ( acc , r ) => acc && r , true ) ;
3737
You can’t perform that action at this time.
0 commit comments