From acff4850637e816cfd01f78895e6321df8eac42b Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Mon, 8 Feb 2021 14:44:09 +0800 Subject: [PATCH] Fix patch-xcode --- patches/patch-xcode.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/patches/patch-xcode.js b/patches/patch-xcode.js index 5552fdefb38825..4e8543f8affa79 100644 --- a/patches/patch-xcode.js +++ b/patches/patch-xcode.js @@ -11,26 +11,29 @@ const path = require( 'path' ); const nodeModulesDir = path.join( __dirname, '../', 'node_modules' ); const fetchRNPackageDirs = ( dir ) => { - const dirList = fs.readdirSync( dir ); + const dirList = fs.readdirSync( dir, { withFileTypes: true } ); const packageDirs = []; - dirList.forEach( ( packageName ) => { - const packageDir = path.join( dir, packageName ); - if ( packageName.startsWith( '@' ) ) { - packageDirs.push( ...fetchRNPackageDirs( packageDir ) ); - } else { - const files = fs.readdirSync( packageDir ); - const podSpecs = files.filter( ( file ) => - file.toLowerCase().endsWith( '.podspec' ) - ); - if ( podSpecs.length > 0 ) { - packageDirs.push( { - dir: packageDir, - files: podSpecs, - package: packageName, - } ); + dirList + .filter( ( file ) => file.isDirectory() ) + .map( ( file ) => file.name ) + .forEach( ( packageName ) => { + const packageDir = path.join( dir, packageName ); + if ( packageName.startsWith( '@' ) ) { + packageDirs.push( ...fetchRNPackageDirs( packageDir ) ); + } else { + const files = fs.readdirSync( packageDir ); + const podSpecs = files.filter( ( file ) => + file.toLowerCase().endsWith( '.podspec' ) + ); + if ( podSpecs.length > 0 ) { + packageDirs.push( { + dir: packageDir, + files: podSpecs, + package: packageName, + } ); + } } - } - } ); + } ); return packageDirs; };