Skip to content

Commit

Permalink
chore(scripts): ignore dirs with no package jsons (#6198)
Browse files Browse the repository at this point in the history
  • Loading branch information
siddsriv authored Jun 14, 2024
1 parent fbfce55 commit ac4cdb5
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ readPackages(clientPackages);
checkVersions();

for (const pkg of nonClientPackages) {
const pkgJson = require(path.join(pkg, "package.json"));
const pkgJsonPath = path.join(pkg, "package.json");

// Check if package.json exists before requiring it
if (!fs.existsSync(pkgJsonPath)) {
continue;
}

const pkgJson = require(pkgJsonPath);
const { dependencies = {}, devDependencies = {} } = pkgJson;

for (const [name, version] of Object.entries(dependencies)) {
Expand Down Expand Up @@ -115,7 +122,7 @@ for (const pkg of nonClientPackages) {
}
}

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

readPackages(nonClientPackages);
Expand Down Expand Up @@ -147,7 +154,14 @@ function checkVersions() {

function readPackages(packages) {
for (const pkg of packages) {
const pkgJson = require(path.join(pkg, "package.json"));
const pkgJsonPath = path.join(pkg, "package.json");

// Check if package.json exists before requiring it
if (!fs.existsSync(pkgJsonPath)) {
continue;
}

const pkgJson = require(pkgJsonPath);
const { dependencies = {}, devDependencies = {} } = pkgJson;
for (const [name, version] of Object.entries(dependencies)) {
if (version.startsWith("file:")) {
Expand Down

0 comments on commit ac4cdb5

Please sign in to comment.