Skip to content

Commit 01c4e2b

Browse files
committed
fix release script failing in dry run
1 parent 4ec8aea commit 01c4e2b

1 file changed

Lines changed: 33 additions & 38 deletions

File tree

packages/release/src/index.js

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ const runProjectRootCommand = (command, force) => {
5959
};
6060

6161
const checkBranchSync = () => {
62+
if (noSyncCheck) {
63+
console.log("Skipping sync check.");
64+
return;
65+
}
6266
console.log("Checking if local branch is master...");
6367
const currentBranch = runProjectRootCommand(
6468
"git branch --show-current",
6569
).trim();
66-
if (currentBranch !== "master") {
70+
if (currentBranch !== "master" && !isDryRun) {
6771
console.error(
6872
"Local branch is not master. Please checkout the master branch.",
6973
);
@@ -72,32 +76,26 @@ const checkBranchSync = () => {
7276

7377
console.log("Checking if local master branch is in sync with origin...");
7478

75-
if (noSyncCheck) {
76-
console.log("Skipping sync check.");
77-
} else if (isDryRun) {
78-
console.log("[Dry Run] Checking sync...");
79-
} else {
80-
try {
81-
// Fetch the latest changes from the remote repository
82-
runProjectRootCommand("git fetch origin");
83-
84-
// Get the commit hashes of the local and remote master branches
85-
const localMaster = runProjectRootCommand("git rev-parse master").trim();
86-
const remoteMaster = runProjectRootCommand(
87-
"git rev-parse origin/master",
88-
).trim();
89-
90-
if (localMaster !== remoteMaster) {
91-
console.error(
92-
"Local master branch is not in sync with origin. Please pull the latest changes before proceeding.",
93-
);
94-
process.exit(1);
95-
}
96-
} catch (error) {
97-
console.error("Error checking branch sync status.");
98-
console.error(error);
79+
try {
80+
// Fetch the latest changes from the remote repository
81+
runProjectRootCommand("git fetch origin");
82+
83+
// Get the commit hashes of the local and remote master branches
84+
const localMaster = runProjectRootCommand("git rev-parse master").trim();
85+
const remoteMaster = runProjectRootCommand(
86+
"git rev-parse origin/master",
87+
).trim();
88+
89+
if (localMaster !== remoteMaster && !isDryRun) {
90+
console.error(
91+
"Local master branch is not in sync with origin. Please pull the latest changes before proceeding.",
92+
);
9993
process.exit(1);
10094
}
95+
} catch (error) {
96+
console.error("Error checking branch sync status.");
97+
console.error(error);
98+
process.exit(1);
10199
}
102100
};
103101

@@ -156,9 +154,8 @@ const updatePackage = (newVersion) => {
156154
const checkUncommittedChanges = () => {
157155
console.log("Checking uncommitted changes...");
158156
const status = execSync("git status --porcelain").toString().trim();
159-
if (isDryRun) {
160-
console.log("[Dry Run] Checking uncommitted changes...");
161-
} else if (status) {
157+
158+
if (status && !isDryRun) {
162159
console.error(
163160
"You have uncommitted changes. Please commit or stash them before proceeding.",
164161
);
@@ -168,11 +165,7 @@ const checkUncommittedChanges = () => {
168165

169166
const installDependencies = () => {
170167
console.log("Installing dependencies...");
171-
if (isDryRun) {
172-
console.log("[Dry Run] Dependencies would be installed.");
173-
} else {
174-
runProjectRootCommand("pnpm i");
175-
}
168+
runProjectRootCommand("pnpm i");
176169
};
177170

178171
const buildProject = () => {
@@ -233,11 +226,13 @@ const generateContributors = () => {
233226
contributors.replaceAll("\n", "").replace(/^.*?\[/, "["),
234227
);
235228

236-
fs.writeFileSync(
237-
`${PROJECT_ROOT}/frontend/static/contributors.json`,
238-
JSON.stringify(contributors, null, 2),
239-
"utf8",
240-
);
229+
if (!isDryRun) {
230+
fs.writeFileSync(
231+
`${PROJECT_ROOT}/frontend/static/contributors.json`,
232+
JSON.stringify(contributors, null, 2),
233+
"utf8",
234+
);
235+
}
241236

242237
console.log("Contributors list updated.");
243238
} catch (e) {

0 commit comments

Comments
 (0)