Skip to content

Commit 500f458

Browse files
chrfalchfacebook-github-bot
authored andcommitted
Add utils script to create folders to prebuild React Native core (#51194)
Summary: Pull Request resolved: #51194 This change adds an utils script to set up folders when needed. ## Changelog: [INTERNAL] - Add utils script Test Plan: This is tested in the next diff of the stack. Reviewed By: cortinico Differential Revision: D74393298 Pulled By: cipolleschi fbshipit-source-id: db3db61ec938d2ebe5c0bf5ae0a42aa20c673bb0
1 parent 43bfb5d commit 500f458

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

  • packages/react-native/scripts/ios-prebuild
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
* @oncall react_native
10+
*/
11+
12+
const fs = require('fs');
13+
14+
/**
15+
* Creates a folder if it does not exist
16+
* @param {string} folderPath - The path to the folder
17+
* @returns {string} The path to the created or existing folder
18+
*/
19+
function createFolderIfNotExists(folderPath /*:string*/) /*: string*/ {
20+
if (!fs.existsSync(folderPath)) {
21+
fs.mkdirSync(folderPath, {recursive: true});
22+
if (!fs.existsSync(folderPath)) {
23+
throw new Error(`Failed to create folder: ${folderPath}`);
24+
}
25+
}
26+
return folderPath;
27+
}
28+
29+
module.exports = {createFolderIfNotExists};

0 commit comments

Comments
 (0)