/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/scripts/swiftpm/utils.js
73 строки
2 KB
Riccardo Cipolleschi
Add function to extract headers from a folder (#53737)
22 сен 2025, 20:14
22 сен 2025, 20:14
072b105
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format */ const {execSync} = require('child_process'); const fs = require('fs'); const path = require('path'); function listHeadersInFolder( folder /*: string */, excludeSubfolders /*: Array<string> */, ) /*: Array<string> */ { try { // Build find command with exclusions using -prune let findCommand = `find "${folder}"`; // Add exclusions for specified folders using -prune if (excludeSubfolders.length > 0) { const pruneConditions = excludeSubfolders .map(subfolder => `-name "${subfolder}"`) .join(' -o '); findCommand += ` \\( ${pruneConditions} \\) -prune -o`; } findCommand += ` \\( -name "*.h" -o -name "*.hpp" \\) -type f -print`; const result = execSync(findCommand, { encoding: 'utf8', stdio: 'pipe', }); const headerFiles = result .trim() .split('\n') .filter(p => p.length > 0); return headerFiles; } catch (error) { console.error(`Failed to process headers from ${folder}:`, error.message); throw error; } } function setupSymlink( sourceFilePath /*: string */, destFilePath /*: string */, ) { const destFolderPath = path.dirname(destFilePath); if (!fs.existsSync(destFolderPath)) { fs.mkdirSync(destFolderPath, {recursive: true}); } // Remove existing symlink if it exists if (fs.existsSync(destFilePath)) { fs.unlinkSync(destFilePath); } // Create symlink for umbrella header if (fs.existsSync(sourceFilePath)) { fs.symlinkSync(sourceFilePath, destFilePath); } } module.exports = { setupSymlink, listHeadersInFolder, };