mirror of
https://github.com/facebook/react-native.git
synced 2024-11-22 06:29:46 +00:00
ee9c1a5260
Summary: Changelog: [General][Changed] - `eslint-plugin-specs` package has prepack hook that changes `PACKAGE_USAGE` variable of `react-native-modules.js` to `true`. This changed file is can then be published to NPM, but should not be committed to the repo. This diff adds postpack hook that reverts the change, so we do not have to do it manually. Reviewed By: cipolleschi Differential Revision: D38244367 fbshipit-source-id: 818dbdea82e7e4b89094b3e27ae2d63b9e736659
45 lines
978 B
JavaScript
45 lines
978 B
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
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
|
|
/**
|
|
* script to prepare package for publish.
|
|
*
|
|
* Due to differences to how we consume internal packages, update a flag
|
|
*/
|
|
|
|
fs.readFile('./react-native-modules.js', 'utf8', function (readError, source) {
|
|
if (readError != null) {
|
|
return console.error(
|
|
'Failed to read react-native-modules.js for publish',
|
|
readError,
|
|
);
|
|
}
|
|
|
|
const result = source.replace(
|
|
'const PACKAGE_USAGE = true;',
|
|
'const PACKAGE_USAGE = false;',
|
|
);
|
|
|
|
fs.writeFile(
|
|
'./react-native-modules.js',
|
|
result,
|
|
'utf8',
|
|
function (writeError) {
|
|
if (writeError != null) {
|
|
return console.error(
|
|
'Failed to update react-native-modules.js for publish',
|
|
writeError,
|
|
);
|
|
}
|
|
},
|
|
);
|
|
});
|