Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pnpm link --global <pkg> should not change the type of the depen…
…dency
- Loading branch information
Showing
12 changed files
with
172 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@pnpm/core": patch | ||
"@pnpm/manifest-utils": patch | ||
"@pnpm/plugin-commands-installation": patch | ||
"@pnpm/types": patch | ||
--- | ||
|
||
`pnpm link --global <pkg>` should not change the type of the dependency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/manifest-utils/src/getAllDependenciesFromManifest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/manifest-utils/src/getDependencyTypeFromManifest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ProjectManifest, DependenciesManifestField } from '@pnpm/types' | ||
|
||
export const getDependencyTypeFromManifest = ( | ||
manifest: Pick<ProjectManifest, DependenciesManifestField>, | ||
depName: string | ||
): DependenciesManifestField | null => { | ||
if (manifest.optionalDependencies?.[depName]) return 'optionalDependencies' | ||
else if (manifest.peerDependencies?.[depName]) return 'peerDependencies' | ||
else if (manifest.dependencies?.[depName]) return 'dependencies' | ||
else if (manifest.devDependencies?.[depName]) return 'devDependencies' | ||
else return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/manifest-utils/test/getDependencyTypeFromManifest.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { getDependencyTypeFromManifest } from '@pnpm/manifest-utils' | ||
|
||
test('getDependencyTypeFromManifest()', () => { | ||
expect( | ||
getDependencyTypeFromManifest({ | ||
dependencies: { | ||
foo: '1.0.0', | ||
}, | ||
}, 'foo')).toEqual('dependencies') | ||
|
||
expect( | ||
getDependencyTypeFromManifest({ | ||
devDependencies: { | ||
foo: '1.0.0', | ||
}, | ||
}, 'foo')).toEqual('devDependencies') | ||
|
||
expect( | ||
getDependencyTypeFromManifest({ | ||
optionalDependencies: { | ||
foo: '1.0.0', | ||
}, | ||
}, 'foo')).toEqual('optionalDependencies') | ||
|
||
expect( | ||
getDependencyTypeFromManifest({ | ||
peerDependencies: { | ||
foo: '1.0.0', | ||
}, | ||
}, 'foo')).toEqual('peerDependencies') | ||
|
||
expect( | ||
getDependencyTypeFromManifest({ | ||
peerDependencies: { | ||
foo: '1.0.0', | ||
}, | ||
}, 'bar')).toEqual(null) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters