Skip to content

Commit

Permalink
[cli] add npmrc file for pnpm projects that use NativeWind and Expo R…
Browse files Browse the repository at this point in the history
…outer
  • Loading branch information
danstepanov committed May 20, 2024
1 parent 8a390cc commit b5340ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-boats-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-expo-stack': patch
---

add npmrc file for pnpm projects that use NativeWind and Expo Router
2 changes: 1 addition & 1 deletion cli/src/utilities/configureProjectFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function configureProjectFiles(

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

Expand Down
7 changes: 6 additions & 1 deletion cli/src/utilities/getPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ import { CliResults } from '../types';
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
export type PackageManagerRunnerX = 'npx' | 'pnpx' | 'yarn dlx' | 'bunx';

// TODO: Rework this function as it is pretty messy
export function getPackageManager(toolbox: Toolbox, cliResults: CliResults): PackageManager {
const {
parameters: { options }
} = toolbox;

if (options.npm) return 'npm';
if (options.yarn) return 'yarn';
if (options.pnpm) return 'pnpm';
if (options.bun) return 'bun';

if (cliResults.flags.packageManager !== 'npm') {
return cliResults.flags.packageManager;
}

// This environment variable is set by npm and yarn but pnpm seems less consistent
const userAgent = process.env.npm_config_user_agent;

if (userAgent) {
if (userAgent.startsWith('yarn')) {
return 'yarn';
Expand Down

0 comments on commit b5340ed

Please sign in to comment.