Skip to content

Commit

Permalink
fix(shadcn-ui): Fixed user input not propagating to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs committed Dec 7, 2024
1 parent 131e048 commit c7b8a51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
13 changes: 10 additions & 3 deletions packages/core/src/utils/exec-package-manager-command.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { detectPackageManager, getPackageManagerCommand } from 'nx/src/utils/package-manager'
import {
detectPackageManager,
getPackageManagerCommand as nxGetPackageManagerCommand
} from 'nx/src/utils/package-manager'

import { buildCommand } from './build-command'
import { execCommand, Options } from './exec'

export function getPackageManagerDlxCommand() {
return getPackageManagerCommand(detectPackageManager()).dlx
return nxGetPackageManagerCommand(detectPackageManager()).dlx
}

export function getPackageManagerCommand() {
return process.env.NX_EXTEND_COMMAND_USE_NPX ? 'npx' : getPackageManagerDlxCommand()
}

export function execPackageManagerCommand(command: string, options?: Options) {
return execCommand(buildCommand([
process.env.NX_EXTEND_COMMAND_USE_NPX ? 'npx' : getPackageManagerDlxCommand(),
getPackageManagerCommand(),
command
]), options)
}
38 changes: 19 additions & 19 deletions packages/shadcn-ui/src/executors/add/add.impl.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { ExecutorContext } from '@nx/devkit'
import { buildCommand, execPackageManagerCommand } from '@nx-extend/core'
import { workspaceRoot } from '@nx/devkit'
import { buildCommand, getPackageManagerCommand } from '@nx-extend/core'
import { execSync } from 'child_process'

export interface ExecutorSchema {
component?: string
overwrite?: boolean
}

export async function addExecutor(
options: ExecutorSchema,
context: ExecutorContext
): Promise<{ success: boolean }> {
return execPackageManagerCommand(
buildCommand([
'shadcn@latest add',
(options.component ?? '').length === 0 ? '--all' : options.component,
options.overwrite && '--overwrite'
]),
{
env: {
...process.env,
TS_NODE_PROJECT: 'tsconfig.base.json'
}
}
)
export async function addExecutor(options: ExecutorSchema): Promise<{ success: boolean }> {
execSync(buildCommand([
getPackageManagerCommand(),
'shadcn@latest add',
(options.component ?? '').length === 0 ? '--all' : options.component,
options.overwrite && '--overwrite'
]), {
cwd: workspaceRoot,
env: {
...process.env,
TS_NODE_PROJECT: 'tsconfig.base.json'
},
stdio: 'inherit'
})

return { success: true }
}

export default addExecutor

0 comments on commit c7b8a51

Please sign in to comment.