Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small error message added when running changesets in a mono repo with… #997

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/afraid-ways-buy.md
@@ -0,0 +1,5 @@
---
"@changesets/cli": patch
---

Add error message when running changesets in a repo with pnpm/yarn workspaces configured by no packages yet
Andarist marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 9 additions & 3 deletions packages/cli/src/commands/add/index.ts
Expand Up @@ -20,7 +20,13 @@ export default async function add(
{ empty, open }: { empty?: boolean; open?: boolean },
config: Config
) {
const packages = (await getPackages(cwd)).packages.filter((pkg) =>
const packages = await getPackages(cwd);
if (packages.packages.length === 0) {
throw new Error(
`No packages found in the current directory. You might have ${packages.tool} workspaces configured by no packages yet?`
JakeGinnivan marked this conversation as resolved.
Show resolved Hide resolved
);
}
const listablePackages = packages.packages.filter((pkg) =>
isListablePackage(config, pkg.packageJson)
);
const changesetBase = path.resolve(cwd, ".changeset");
Expand All @@ -41,8 +47,8 @@ export default async function add(
.filter((pkg) => isListablePackage(config, pkg.packageJson))
.map((pkg) => pkg.packageJson.name);

newChangeset = await createChangeset(changedPackagesName, packages);
printConfirmationMessage(newChangeset, packages.length > 1);
newChangeset = await createChangeset(changedPackagesName, listablePackages);
printConfirmationMessage(newChangeset, listablePackages.length > 1);

if (!newChangeset.confirmed) {
newChangeset = {
Expand Down