Skip to content

Commit

Permalink
fix(cli): folder creation in add command
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-karger committed Oct 23, 2023
1 parent eb03975 commit d7ed904
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/cli/src/commands/add.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs"
import path from "path"
import { cwd } from "process"

import { log, spinner } from "@clack/prompts"
Expand Down Expand Up @@ -49,13 +50,13 @@ export async function add(componentNames: string[]) {
activityIndicator.start("Creating components...")

try {
const readSUCConfig = readFileSync(cwd() + "/suc.config.json")
const readSUCConfig = readFileSync(path.resolve(cwd(), "suc.config.json"))
const sucConfig = parse(configSchema, JSON.parse(readSUCConfig.toString()))
const isTypescriptEnabled = sucConfig.tsx
const componentFolderDir = cwd() + "/" + sucConfig.componentDir
const componentFolderDir = path.resolve(cwd(), sucConfig.componentDir)
const dirExists = existsSync(componentFolderDir)

if (!dirExists) mkdirSync(componentFolderDir)
if (!dirExists) mkdirSync(componentFolderDir, { recursive: true })

const components = await Promise.all(
componentNames.map(async (name) => await getComponent(name))
Expand Down

0 comments on commit d7ed904

Please sign in to comment.