Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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