Skip to content

Commit ac4cdb5

Browse files
authored
chore(scripts): ignore dirs with no package jsons (#6198)
1 parent fbfce55 commit ac4cdb5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

scripts/runtime-dependency-version-check/runtime-dep-version-check.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ readPackages(clientPackages);
5454
checkVersions();
5555

5656
for (const pkg of nonClientPackages) {
57-
const pkgJson = require(path.join(pkg, "package.json"));
57+
const pkgJsonPath = path.join(pkg, "package.json");
58+
59+
// Check if package.json exists before requiring it
60+
if (!fs.existsSync(pkgJsonPath)) {
61+
continue;
62+
}
63+
64+
const pkgJson = require(pkgJsonPath);
5865
const { dependencies = {}, devDependencies = {} } = pkgJson;
5966

6067
for (const [name, version] of Object.entries(dependencies)) {
@@ -115,7 +122,7 @@ for (const pkg of nonClientPackages) {
115122
}
116123
}
117124

118-
fs.writeFileSync(path.join(pkg, "package.json"), JSON.stringify(pkgJson, null, 2) + "\n", "utf-8");
125+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + "\n", "utf-8");
119126
}
120127

121128
readPackages(nonClientPackages);
@@ -147,7 +154,14 @@ function checkVersions() {
147154

148155
function readPackages(packages) {
149156
for (const pkg of packages) {
150-
const pkgJson = require(path.join(pkg, "package.json"));
157+
const pkgJsonPath = path.join(pkg, "package.json");
158+
159+
// Check if package.json exists before requiring it
160+
if (!fs.existsSync(pkgJsonPath)) {
161+
continue;
162+
}
163+
164+
const pkgJson = require(pkgJsonPath);
151165
const { dependencies = {}, devDependencies = {} } = pkgJson;
152166
for (const [name, version] of Object.entries(dependencies)) {
153167
if (version.startsWith("file:")) {

0 commit comments

Comments
 (0)