author doubledream
 *  desc import * as path from 'path' ; import * as _ from 'lodash' ; import * as fs from 'fs' ; function param { string } dir param { ignoreDirectory } 忽略文件夹 function getSpecifiedFiles ( dir , ignoreDirectory = '' , ignoreFile = '' ) { return fs . readdirSync ( dir ) . reduce ( ( files , file ) => { const name = path . join ( dir , file ) ; const isDirectory = fs . statSync ( name ) . isDirectory ( ) ; const isFile = fs . statSync ( name ) . isFile ( ) ; if ( isDirectory ) { return files . concat ( getSpecifiedFiles ( name , ignoreDirectory , ignoreFile ) ) ; } const isIgnoreDirectory = ! ignoreDirectory || ( ignoreDirectory && ! path . dirname ( name ) . split ( '/' ) . includes ( ignoreDirectory ) ) ; const isIgnoreFile = ! ignoreFile || ( ignoreFile && path . basename ( name ) !== ignoreFile ) ; if ( isFile && isIgnoreDirectory && isIgnoreFile ) { return files . concat ( name ) ; } return files ; } , [ ] ) ; } param fileName function readFile ( fileName ) { if ( fs . existsSync ( fileName ) ) { return fs . readFileSync ( fileName , 'utf-8' ) ; } } param fileName function writeFile ( filePath , file ) { if ( fs . existsSync ( filePath ) ) { fs . writeFileSync ( filePath , file ) ; } } export { getSpecifiedFiles , readFile , writeFile } ;