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 663810b
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 @@ -8,14 +8,18 @@ export function getPackageManager(toolbox: Toolbox, cliResults: CliResults): Pac
const {
parameters: { options }
} = toolbox;

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

// This environment variable is set by npm and yarn but pnpm seems less consistent
const userAgent = process.env.npm_config_user_agent;
console.log('userAgent', userAgent);
if (userAgent) {
if (userAgent.startsWith('yarn')) {
return 'yarn';
Expand All @@ -27,6 +31,7 @@ export function getPackageManager(toolbox: Toolbox, cliResults: CliResults): Pac
return 'npm';
}
} else {
console.log('cliResults.flags.packageManager', cliResults.flags.packageManager);
// If no user agent is set, assume npm
return cliResults.flags.packageManager;
}
Expand Down

0 comments on commit 663810b

Please sign in to comment.