Skip to content

Commit

Permalink
fix: do not hardcode npx in shadcn-ui:add executor (#246)
Browse files Browse the repository at this point in the history
Fixes #245
  • Loading branch information
TriPSs authored Mar 27, 2024
2 parents a733ff2 + c6be2b6 commit f2492ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/utils/exec-package-manager-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { detectPackageManager, getPackageManagerCommand } from 'nx/src/utils/pac
import { buildCommand } from './build-command'
import { execCommand, Options } from './exec'

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

export function execPackageManagerCommand(command: string, options?: Options) {
return execCommand(buildCommand([
process.env.NX_EXTEND_COMMAND_USE_NPX ? 'npx' : getPackageManagerExecCommand(),
process.env.NX_EXTEND_COMMAND_USE_NPX ? 'npx' : getPackageManagerDlxCommand(),
command
]), options)
}
4 changes: 2 additions & 2 deletions packages/e2e-runner/src/executors/run/utils/nx-target.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logger, parseTargetString } from '@nx/devkit'
import { readCachedProjectGraph } from '@nx/workspace/src/core/project-graph'
import { getPackageManagerExecCommand, USE_VERBOSE_LOGGING } from '@nx-extend/core'
import { getPackageManagerDlxCommand, USE_VERBOSE_LOGGING } from '@nx-extend/core'
import * as childProcess from 'child_process'

import { isApiLive } from './is-api-live'
Expand Down Expand Up @@ -172,7 +172,7 @@ function launchProcess(
const shouldLog = options.logging ?? USE_VERBOSE_LOGGING

const spawnedProcess = childProcess.spawn(
`${getPackageManagerExecCommand()} nx ${target} ${project} ${
`${getPackageManagerDlxCommand()} nx ${target} ${project} ${
configuration ? `--configuration=${configuration}` : ''
}`,
[],
Expand Down
6 changes: 3 additions & 3 deletions packages/shadcn-ui/src/executors/add/add.impl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExecutorContext } from '@nx/devkit'
import { buildCommand, execCommand } from '@nx-extend/core'
import { buildCommand, execPackageManagerCommand } from '@nx-extend/core'

export interface ExecutorSchema {
component: string
Expand All @@ -12,8 +12,8 @@ export async function addExecutor(
): Promise<{ success: boolean }> {
const { root } = context.workspace.projects[context.projectName]

return execCommand(buildCommand([
'npx shadcn-ui@latest add',
return execPackageManagerCommand(buildCommand([
'shadcn-ui@latest add',
options.component,
options.overwrite && '--overwrite',
'--path=src',
Expand Down

0 comments on commit f2492ec

Please sign in to comment.