Files
react-native/scripts/codegen/codegen-utils.js
T
shivenmian b7a85b59b5 chore: renamed react-native-codegen to @react-native/codegen (#34804)
Summary:
Renamed react-native-codegen package to react-native/codegen and updated references, without changing the folder name; part of RFC480 (https://github.com/facebook/react-native/issues/34692). Follow-up from https://github.com/facebook/react-native/pull/34578

## Changelog

[General] [Changed] - Renamed react-native-codegen package to react-native/codegen and updated references

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Reviewed By: cortinico

Differential Revision: D39883584

Pulled By: hoxyq

fbshipit-source-id: 0ef384b75c6edd248b31e37b8f05f64b4d39ca6f
2022-11-28 08:28:51 -08:00

38 lines
1.0 KiB
JavaScript

/**
* 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.
*
* @format
*/
'use strict';
/**
* Wrapper required to abstract away from the actual codegen.
* This is needed because, when running tests in Sandcastle, not everything is setup as usually.
* For example, the `@react-native/codegen` lib is not present.
*
* Thanks to this wrapper, we are able to mock the getter for the codegen in a way that allow us to return
* a custom object which mimics the Codegen interface.
*
* @return an object that can generate the code for the New Architecture.
*/
function getCodegen() {
let RNCodegen;
try {
RNCodegen = require('../../packages/react-native-codegen/lib/generators/RNCodegen.js');
} catch (e) {
RNCodegen = require('@react-native/codegen/lib/generators/RNCodegen.js');
}
if (!RNCodegen) {
throw 'RNCodegen not found.';
}
return RNCodegen;
}
module.exports = {
getCodegen: getCodegen,
};