MCPcopy Index your code
hub / github.com/craftreactnative/ui / installDependency

Function installDependency

cli/src/commands/init.ts:250–271  ·  view source on GitHub ↗
(
  dep: string,
  isExpoProject: boolean
)

Source from the content-addressed store, hash-verified

248}
249
250async function installDependency(
251 dep: string,
252 isExpoProject: boolean
253): Promise<void> {
254 const packageName = dep.split("@")[0];
255 const targetPath = process.cwd();
256
257 // For native dependencies in Expo projects, use expo install
258 const isExpoDep =
259 packageName.includes("react-native-svg") ||
260 packageName.includes("react-native-reanimated") ||
261 packageName.includes("react-native-gesture-handler");
262
263 if (isExpoProject && isExpoDep) {
264 await execAsync(`npx expo install ${packageName}`, { cwd: targetPath });
265 } else {
266 // For unistyles or non-Expo projects, use regular package manager
267 const packageManager = await detectPackageManager(targetPath);
268 const installCommand = getInstallCommand(packageManager, dep);
269 await execAsync(installCommand, { cwd: targetPath });
270 }
271}
272
273async function detectPackageManager(
274 targetPath: string

Callers 1

initCommandFunction · 0.85

Calls 2

detectPackageManagerFunction · 0.85
getInstallCommandFunction · 0.85

Tested by

no test coverage detected