Skip to content

Commit ee9c1a5

Browse files
Dmitry Rykunfacebook-github-bot
authored andcommitted
Add postpack hook that undoes prepack
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
1 parent 1af2bea commit ee9c1a5

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

packages/eslint-plugin-specs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"directory": "packages/eslint-plugin-specs"
1010
},
1111
"scripts": {
12-
"prepack": "node prepack.js"
12+
"prepack": "node prepack.js",
13+
"postpack": "node postpack.js"
1314
},
1415
"dependencies": {
1516
"@babel/core": "^7.14.0",
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
const fs = require('fs');
11+
12+
/**
13+
* script to prepare package for publish.
14+
*
15+
* Due to differences to how we consume internal packages, update a flag
16+
*/
17+
18+
fs.readFile('./react-native-modules.js', 'utf8', function (readError, source) {
19+
if (readError != null) {
20+
return console.error(
21+
'Failed to read react-native-modules.js for publish',
22+
readError,
23+
);
24+
}
25+
26+
const result = source.replace(
27+
'const PACKAGE_USAGE = true;',
28+
'const PACKAGE_USAGE = false;',
29+
);
30+
31+
fs.writeFile(
32+
'./react-native-modules.js',
33+
result,
34+
'utf8',
35+
function (writeError) {
36+
if (writeError != null) {
37+
return console.error(
38+
'Failed to update react-native-modules.js for publish',
39+
writeError,
40+
);
41+
}
42+
},
43+
);
44+
});

0 commit comments

Comments
 (0)