@@ -16,11 +16,21 @@ import paths = require('path');
1616
1717const loop = flow . loop ;
1818
19+ export function readdirSync ( path : string ) : string [ ] {
20+ // Mac: uses NFD unicode form on disk, but we want NFC
21+ // See also https://github.com/nodejs/node/issues/2165
22+ if ( platform . isMacintosh ) {
23+ return fs . readdirSync ( path ) . map ( c => strings . normalizeNFC ( c ) ) ;
24+ }
25+
26+ return fs . readdirSync ( path ) ;
27+ }
28+
1929export function readdir ( path : string , callback : ( error : Error , files : string [ ] ) => void ) : void {
2030 // Mac: uses NFD unicode form on disk, but we want NFC
2131 // See also https://github.com/nodejs/node/issues/2165
2232 if ( platform . isMacintosh ) {
23- return readdirNormalize ( path , ( error , children ) => {
33+ return fs . readdir ( path , ( error , children ) => {
2434 if ( error ) {
2535 return callback ( error , null ) ;
2636 }
@@ -29,22 +39,7 @@ export function readdir(path: string, callback: (error: Error, files: string[])
2939 } ) ;
3040 }
3141
32- return readdirNormalize ( path , callback ) ;
33- }
34-
35- function readdirNormalize ( path : string , callback : ( error : Error , files : string [ ] ) => void ) : void {
36- fs . readdir ( path , ( error , children ) => {
37- if ( error ) {
38- return callback ( error , null ) ;
39- }
40-
41- // Bug in node: In some environments we get "." and ".." as entries from the call to readdir().
42- // For example Sharepoint via WebDav on Windows includes them. We never want those
43- // entries in the result set though because they are not valid children of the folder
44- // for our concerns.
45- // See https://github.com/nodejs/node/issues/4002
46- return callback ( null , children . filter ( c => c !== '.' && c !== '..' ) ) ;
47- } ) ;
42+ return fs . readdir ( path , callback ) ;
4843}
4944
5045export function mkdirp ( path : string , mode : number , callback : ( error : Error ) => void ) : void {
0 commit comments