Skip to content

Commit b5340ed

Browse files
committed
[cli] add npmrc file for pnpm projects that use NativeWind and Expo Router
1 parent 8a390cc commit b5340ed

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

.changeset/smooth-boats-exercise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-expo-stack': patch
3+
---
4+
5+
add npmrc file for pnpm projects that use NativeWind and Expo Router

cli/src/utilities/configureProjectFiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function configureProjectFiles(
3232

3333
const packageManager = getPackageManager(toolbox, cliResults);
3434
// Add npmrc file if user is using pnpm and expo router
35-
if (packageManager === 'pnpm' && navigationPackage?.name === 'expo-router') {
35+
if (packageManager === 'pnpm') {
3636
baseFiles.push('base/.npmrc.ejs');
3737
}
3838

cli/src/utilities/getPackageManager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@ import { CliResults } from '../types';
44
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
55
export type PackageManagerRunnerX = 'npx' | 'pnpx' | 'yarn dlx' | 'bunx';
66

7+
// TODO: Rework this function as it is pretty messy
78
export function getPackageManager(toolbox: Toolbox, cliResults: CliResults): PackageManager {
89
const {
910
parameters: { options }
1011
} = toolbox;
11-
1212
if (options.npm) return 'npm';
1313
if (options.yarn) return 'yarn';
1414
if (options.pnpm) return 'pnpm';
1515
if (options.bun) return 'bun';
1616

17+
if (cliResults.flags.packageManager !== 'npm') {
18+
return cliResults.flags.packageManager;
19+
}
20+
1721
// This environment variable is set by npm and yarn but pnpm seems less consistent
1822
const userAgent = process.env.npm_config_user_agent;
23+
1924
if (userAgent) {
2025
if (userAgent.startsWith('yarn')) {
2126
return 'yarn';

0 commit comments

Comments
 (0)