mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-07 14:08:47 +00:00
feat: wip for init
This commit is contained in:
@@ -9,6 +9,7 @@ import { TEMP_DIR } from "./setup"
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const FIXTURES_DIR = path.join(__dirname, "../../fixtures")
|
||||
const SHADCN_CLI_PATH = path.join(__dirname, "../../../shadcn/dist/index.js")
|
||||
const TEMPLATES_DIR = path.join(__dirname, "../../../../templates")
|
||||
|
||||
export function getRegistryUrl() {
|
||||
return process.env.REGISTRY_URL || "http://localhost:4000/r"
|
||||
@@ -32,6 +33,7 @@ export async function runCommand(
|
||||
options?: {
|
||||
env?: Record<string, string>
|
||||
input?: string
|
||||
timeout?: number
|
||||
}
|
||||
) {
|
||||
try {
|
||||
@@ -45,7 +47,7 @@ export async function runCommand(
|
||||
},
|
||||
input: options?.input,
|
||||
reject: false,
|
||||
timeout: 30000,
|
||||
timeout: options?.timeout ?? 30000,
|
||||
})
|
||||
|
||||
const result = await childProcess
|
||||
@@ -69,14 +71,18 @@ export async function npxShadcn(
|
||||
args: string[],
|
||||
{
|
||||
debug = false,
|
||||
timeout,
|
||||
}: {
|
||||
debug?: boolean
|
||||
timeout?: number
|
||||
} = {}
|
||||
) {
|
||||
const result = await runCommand(cwd, args, {
|
||||
env: {
|
||||
REGISTRY_URL: getRegistryUrl(),
|
||||
SHADCN_TEMPLATE_DIR: TEMPLATES_DIR,
|
||||
},
|
||||
timeout,
|
||||
})
|
||||
|
||||
if (debug) {
|
||||
|
||||
Reference in New Issue
Block a user