chore: replace mkdirp with mkdir fs (#46388)

Summary:
This pull request replaces the use of mkdirp with Node.js's built-in fs.mkdirSync({ recursive: true }) function, which is available in Node.js version 10.12.0 and above. This change reduces the number of external dependencies and simplifies the codebase by using the native capabilities of Node.js.

The motivation behind this change is to remove the unnecessary mkdirp dependency, as Node.js natively supports recursive directory creation since version 10.12.0. This streamlines the code and reduces the reliance on external libraries.

## Changelog:

[INTERNAL] [REMOVED] - Replaced mkdirp with fs.mkdirSync({ recursive: true }) in build scripts and codegen. Requires Node.js 10.12.0 and above.

Pull Request resolved: https://github.com/facebook/react-native/pull/46388

Test Plan: I ran the build and codegen scripts locally with Node.js version 10.12.0 and above after replacing mkdirp, ensuring the scripts work as expected. No issues were encountered, and all processes, including directory creation and file handling, function correctly.

Reviewed By: cortinico

Differential Revision: D62852488

Pulled By: huntie

fbshipit-source-id: 76f44102a80b499521c156308d276a17d279ce38
This commit is contained in:
anirudh.bharti
2024-09-17 07:03:44 -07:00
committed by Facebook GitHub Bot
parent 3c17beafe3
commit 7cdb87eb19
12 changed files with 23 additions and 63 deletions
+2 -2
View File
@@ -27,7 +27,6 @@ const chalk = require('chalk');
const fs = require('fs');
const glob = require('glob');
const micromatch = require('micromatch');
const mkdirp = require('mkdirp');
const path = require('path');
const prettier = require('prettier');
const prettierConfig = JSON.parse(
@@ -60,7 +59,8 @@ function getBuildPath(file, buildFolder) {
function buildFile(file, silent) {
const destPath = getBuildPath(file, BUILD_DIR);
mkdirp.sync(path.dirname(destPath));
fs.mkdirSync(path.dirname(destPath), {recursive: true});
if (micromatch.isMatch(file, IGNORE_PATTERN)) {
silent ||
process.stdout.write(