generated from nhcarrigan/template
feat: handle package checking better
This commit is contained in:
@@ -333,19 +333,20 @@ const handleNewBranch = async(
|
|||||||
const { path: repoPath } = clonedRepo;
|
const { path: repoPath } = clonedRepo;
|
||||||
|
|
||||||
await runGitCommand(logger, repoPath, "git checkout main");
|
await runGitCommand(logger, repoPath, "git checkout main");
|
||||||
await runGitCommand(logger, repoPath, `git checkout -b ${branchName}`);
|
|
||||||
|
|
||||||
|
// Check if package exists before creating branch
|
||||||
const currentVersion = await getCurrentVersionOnBranch(repoPath, packageName);
|
const currentVersion = await getCurrentVersionOnBranch(repoPath, packageName);
|
||||||
if (currentVersion === null) {
|
if (currentVersion === null) {
|
||||||
void logger.log("warn", `Package ${packageName} not found in package.json`);
|
void logger.log("warn", `Package ${packageName} not found in package.json`);
|
||||||
await runGitCommand(logger, repoPath, "git checkout main");
|
|
||||||
await runGitCommand(logger, repoPath, `git branch -D ${branchName}`);
|
|
||||||
return {
|
return {
|
||||||
error: `Package ${packageName} not found in package.json`,
|
error: `Package ${packageName} not found in package.json`,
|
||||||
status: "failed",
|
status: "failed",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only create branch if package exists
|
||||||
|
await runGitCommand(logger, repoPath, `git checkout -b ${branchName}`);
|
||||||
|
|
||||||
await updatePackageAndCommit({
|
await updatePackageAndCommit({
|
||||||
logger,
|
logger,
|
||||||
packageName,
|
packageName,
|
||||||
|
|||||||
Reference in New Issue
Block a user