Skip to content

Commit abad4b0

Browse files
committed
Fix package publishing script
0748616 changed the workspace configuration with the result that 'react-native-web' appeared twice in the array of workspaces, causing an attempt to republish the package during the release task.
1 parent e9f9463 commit abad4b0

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

scripts/releaseReactNativeWebPackages.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,24 @@ const oneTimeCode = argv.otp;
1818
console.log(`Publishing react-native-web@${version}`);
1919

2020
// Collect 'react-native-web' workspaces and package manifests
21-
const workspacePaths = require('../package.json').workspaces;
22-
const workspaces = workspacePaths.reduce((acc, curr) => {
23-
const packageDirectories = glob.sync(curr);
24-
const subsetOfpackageDirectories = packageDirectories.filter((dir) => {
25-
return dir.includes('react-native-web');
26-
});
27-
subsetOfpackageDirectories.forEach((dir) => {
28-
const directory = path.resolve(dir);
29-
const packageJsonPath = path.join(directory, 'package.json');
30-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
31-
acc.push({ directory, packageJson, packageJsonPath });
21+
const workspacePaths = require('../package.json').workspaces.reduce((acc, w) => {
22+
const resolvedPaths = glob.sync(w);
23+
resolvedPaths.forEach((p) => {
24+
// Remove duplicates and unrelated packages
25+
if (p.includes('react-native-web') && acc.indexOf(p) === -1) {
26+
acc.push(p);
27+
}
3228
});
3329
return acc;
3430
}, []);
3531

32+
const workspaces = workspacePaths.map((dir) => {
33+
const directory = path.resolve(dir);
34+
const packageJsonPath = path.join(directory, 'package.json');
35+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
36+
return { directory, packageJson, packageJsonPath };
37+
});
38+
3639
// Update each package version and its dependencies
3740
const workspaceNames = workspaces.map(({ packageJson }) => packageJson.name);
3841
workspaces.forEach(({ directory, packageJson, packageJsonPath }) => {

0 commit comments

Comments
 (0)