import * as fs from 'fs' ; import * as p from 'path' ; export function rimrafUnlink ( path ) { try { const stat = fs . lstatSync ( path ) ; if ( stat . isDirectory ( ) && ! stat . isSymbolicLink ( ) ) { const children = fs . readdirSync ( path ) ; children . map ( child => rimrafUnlink ( p . join ( path , child ) ) ) ; fs . rmdirSync ( path ) ; } else { const mode = stat . mode ; if ( ! ( mode & 128 ) ) { fs . chmodSync ( path , mode | 128 ) ; } return fs . unlinkSync ( path ) ; } } catch ( error ) { if ( error . code !== 'ENOENT' ) { throw error ; } } } export function mkdirRecursive ( path ) { if ( ! fs . existsSync ( path ) ) { if ( p . parse ( path ) . root != path ) { let parent = p . join ( path , ".." ) ; mkdirRecursive ( parent ) ; } fs . mkdirSync ( path ) ; } }