Skip to content

Commit

Permalink
fix: Update utils in its proper language mode (#982)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGonz97 authored Apr 2, 2024
1 parent 8ee4796 commit 7f487a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-coats-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-svelte": patch
---

fix: Updating `utils` in JS mode now updates with the proper syntax
8 changes: 6 additions & 2 deletions packages/cli/src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { type Config, getConfig } from "../utils/get-config.js";
import { getPackageManager } from "../utils/get-package-manager.js";
import { error, handleError } from "../utils/errors.js";
import { fetchTree, getItemTargetPath, getRegistryIndex, resolveTree } from "../utils/registry";
import { UTILS } from "../utils/templates.js";
import { UTILS, UTILS_JS } from "../utils/templates.js";
import { transformImports } from "../utils/transformers.js";
import * as p from "../utils/prompts.js";
import { intro, prettifyList } from "../utils/prompt-helpers.js";
Expand Down Expand Up @@ -166,7 +166,11 @@ async function runUpdate(cwd: string, config: Config, options: UpdateOptions) {
}

// utils.(ts|js) is not in the registry, it is a template, so we'll just overwrite it
await fs.writeFile(utilsPath, UTILS);
if (config.typescript) {
await fs.writeFile(utilsPath, UTILS);
} else {
await fs.writeFile(utilsPath, UTILS_JS);
}
}

const tree = await resolveTree(
Expand Down

0 comments on commit 7f487a5

Please sign in to comment.