Skip to content

Commit

Permalink
fix: update pnpm install flags
Browse files Browse the repository at this point in the history
pnpm v7.0.0 until 7.13.5 uses `--strict-peer-dependencies=true` which causes
a failure when not all `peerDependencies` are installed. By setting the
flag explicitly, this will no longer be a problem for new users.

fix: #1806
  • Loading branch information
jmcdo29 committed Oct 27, 2022
1 parent 30b3421 commit ee5a791
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/package-managers/pnpm.package-manager.ts
Expand Up @@ -16,8 +16,8 @@ export class PnpmPackageManager extends AbstractPackageManager {
// As of PNPM v5.3, all commands are shared with NPM v6.14.5. See: https://pnpm.js.org/en/pnpm-vs-npm
get cli(): PackageManagerCommands {
return {
install: 'install',
add: 'install',
install: 'install --strict-peer-dependencies=false',
add: 'install --strict-peer-dependencies=false',
update: 'update',
remove: 'uninstall',
saveFlag: '--save',
Expand Down
14 changes: 7 additions & 7 deletions test/lib/package-managers/pnpm.package-manager.spec.ts
Expand Up @@ -23,8 +23,8 @@ describe('PnpmPackageManager', () => {
});
it('should have the correct cli commands', () => {
const expectedValues: PackageManagerCommands = {
install: 'install',
add: 'install',
install: 'install --strict-peer-dependencies=false',
add: 'install --strict-peer-dependencies=false',
update: 'update',
remove: 'uninstall',
saveFlag: '--save',
Expand All @@ -39,15 +39,15 @@ describe('PnpmPackageManager', () => {
const dirName = '/tmp';
const testDir = join(process.cwd(), dirName);
packageManager.install(dirName, 'pnpm');
expect(spy).toBeCalledWith('install --reporter=silent', true, testDir);
expect(spy).toBeCalledWith('install --strict-peer-dependencies=false --reporter=silent', true, testDir);
});
});
describe('addProduction', () => {
it('should use the proper command for adding production dependencies', () => {
const spy = jest.spyOn((packageManager as any).runner, 'run');
const dependencies = ['@nestjs/common', '@nestjs/core'];
const tag = '5.0.0';
const command = `install --save ${dependencies
const command = `install --strict-peer-dependencies=false --save ${dependencies
.map((dependency) => `${dependency}@${tag}`)
.join(' ')}`;
packageManager.addProduction(dependencies, tag);
Expand All @@ -59,7 +59,7 @@ describe('PnpmPackageManager', () => {
const spy = jest.spyOn((packageManager as any).runner, 'run');
const dependencies = ['@nestjs/common', '@nestjs/core'];
const tag = '5.0.0';
const command = `install --save-dev ${dependencies
const command = `install --strict-peer-dependencies=false --save-dev ${dependencies
.map((dependency) => `${dependency}@${tag}`)
.join(' ')}`;
packageManager.addDevelopment(dependencies, tag);
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('PnpmPackageManager', () => {
const tag = '5.0.0';
const uninstallCommand = `uninstall --save ${dependencies.join(' ')}`;

const installCommand = `install --save ${dependencies
const installCommand = `install --strict-peer-dependencies=false --save ${dependencies
.map((dependency) => `${dependency}@${tag}`)
.join(' ')}`;

Expand All @@ -110,7 +110,7 @@ describe('PnpmPackageManager', () => {
const tag = '5.0.0';
const uninstallCommand = `uninstall --save-dev ${dependencies.join(' ')}`;

const installCommand = `install --save-dev ${dependencies
const installCommand = `install --strict-peer-dependencies=false --save-dev ${dependencies
.map((dependency) => `${dependency}@${tag}`)
.join(' ')}`;

Expand Down

0 comments on commit ee5a791

Please sign in to comment.