Skip to content

Commit

Permalink
add --nodep flag (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: Hunter Johnston <64506580+huntabyte@users.noreply.github.com>
  • Loading branch information
nothendev and huntabyte committed Jun 3, 2023
1 parent 18429dc commit ae47aa6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-toys-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-svelte": patch
---

add --nodep flag to disable adding and installing dependencies (advanced)
7 changes: 5 additions & 2 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ async function main() {
program
.command("add")
.description("add components to your project")
.option("--nodep", "disable adding & installing dependencies (advanced)")
.argument("[components...]", "name of components")
.action(async (components: string[]) => {
.action(async (options, components: string[]) => {
logger.warn(
"Running the following command will overwrite existing files."
);
Expand Down Expand Up @@ -184,14 +185,16 @@ async function main() {
}

// Install dependencies.
if (component.dependencies?.length) {
if (component.dependencies?.length && !options.nodep) {
await execa(packageManager, [
packageManager === "npm" ? "install" : "add",
...component.dependencies
]);
}
componentSpinner.succeed(component.name);
}

if (options.nodep) logger.warn(`components installed without dependencies, consider adding ${[...new Set(selectedComponents.flatMap(component => component.dependencies ?? []))].join(", ")} to your project dependencies`)
});

program.parse();
Expand Down

0 comments on commit ae47aa6

Please sign in to comment.