MCPcopy Index your code
hub / github.com/npmx-dev/npmx.dev / getRunCommandParts

Function getRunCommandParts

app/utils/run-command.ts:79–107  ·  view source on GitHub ↗
(options: RunCommandOptions)

Source from the content-addressed store, hash-verified

77 * For example: ["pnpm", "exec", "eslint"] or ["pnpm", "dlx", "create-vite"]
78 */
79export function getRunCommandParts(options: RunCommandOptions): string[] {
80 const pm = packageManagers.find(p => p.id === options.packageManager)
81 if (!pm) return []
82
83 const spec = getPackageSpecifier(options)
84
85 // Choose execute command based on package type
86 const executeCmd = options.isBinaryOnly ? pm.executeRemote : pm.executeLocal
87 const executeParts = executeCmd.split(' ')
88
89 // For deno, always use the package specifier
90 if (options.packageManager === 'deno') {
91 return [...executeParts, spec]
92 }
93
94 // For local execute with specific command name different from package name
95 // e.g., `pnpm exec tsc` for typescript package
96 if (options.command && options.command !== options.packageName) {
97 const baseName = getPackageBaseName(options.packageName)
98 // If command matches base package name, use the package spec
99 if (options.command === baseName) {
100 return [...executeParts, spec]
101 }
102 // Otherwise use the command name directly
103 return [...executeParts, options.command]
104 }
105
106 return [...executeParts, spec]
107}
108
109/**
110 * Generate the full run command for a package.

Callers 2

getRunCommandFunction · 0.85

Calls 2

getPackageSpecifierFunction · 0.90
getPackageBaseNameFunction · 0.85

Tested by

no test coverage detected