Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug with the latest version of the mkdirp #1894

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 27 additions & 2 deletions ern-container-gen-ios/src/IosGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,33 @@ Make sure to run these commands before building the container.`,
await yarn.init();
await yarn.add(PackagePath.fromString(`react-native-codegen@${version}`));
// mkdirp and invariant are also needed
await yarn.add(PackagePath.fromString('mkdirp'));
await yarn.add(PackagePath.fromString('invariant'));
const requiredPackages = ['mkdirp', 'invariant'];

let yarnFile = '';
// Check if a yarn.lock file exists
const yarnLockFilePath = targetDir + '/yarn.lock';
if (fs.existsSync(yarnLockFilePath)) {
// Read the yarn.lock file
yarnFile = fs.readFileSync(yarnLockFilePath, {
encoding: 'utf8',
});
}

for (const requiredPackage of requiredPackages) {
// Check if the the required libraries are already in the yarn.lock file (if one exists)
let packageName = requiredPackage;
const re = RegExp(`${packageName}\@(.*):`);
const match = re.exec(yarnFile);

if (match !== null && match[1]) {
// Add the same version specified in the yarn.lock file
packageName += `@${match[1]}`;
}

// Include the required library
await yarn.add(PackagePath.fromString(packageName));
}

shell.rm('-rf', [
'package.json',
'yarn.lock',
Expand Down