mirror of
https://github.com/badges/shields.git
synced 2025-04-18 19:44:04 +03:00
return string instead of object from getDependencyVersion function (#8396)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
parent
ae018cdddc
commit
e3c938b4d7
@ -175,7 +175,7 @@ class GithubPackageJsonDependencyVersion extends ConditionalGithubAuthV3Service
|
||||
})
|
||||
|
||||
const wantedDependency = scope ? `${scope}/${packageName}` : packageName
|
||||
const { range } = getDependencyVersion({
|
||||
const range = getDependencyVersion({
|
||||
kind,
|
||||
wantedDependency,
|
||||
dependencies,
|
||||
|
@ -127,7 +127,7 @@ export default class NpmDependencyVersion extends NpmBase {
|
||||
registryUrl,
|
||||
})
|
||||
|
||||
const { range } = getDependencyVersion({
|
||||
const range = getDependencyVersion({
|
||||
kind,
|
||||
wantedDependency,
|
||||
dependencies,
|
||||
|
@ -45,7 +45,7 @@ const isPackageJsonWithDependencies = Joi.object({
|
||||
* @param {object} attrs.optionalDependencies - Map of optional dependencies
|
||||
* @throws {string} - Error message if unknown dependency type provided
|
||||
* @throws {InvalidParameter} - Error if wanted dependency is not present
|
||||
* @returns {object} Object containing semver range of the wanted dependency (eg. ~2.1.6 or >=3.0.0 or <4.0.0)
|
||||
* @returns {string} Semver range of the wanted dependency (eg. ~2.1.6 or >=3.0.0 or <4.0.0)
|
||||
*/
|
||||
function getDependencyVersion({
|
||||
kind = 'prod',
|
||||
@ -72,7 +72,7 @@ function getDependencyVersion({
|
||||
})
|
||||
}
|
||||
|
||||
return { range }
|
||||
return range
|
||||
}
|
||||
|
||||
export { isDependencyMap, isPackageJsonWithDependencies, getDependencyVersion }
|
||||
|
@ -8,9 +8,8 @@ describe('Package json helpers', function () {
|
||||
dependencies: { 'left-pad': '~1.2.3' },
|
||||
devDependencies: {},
|
||||
peerDependencies: {},
|
||||
}).expect({
|
||||
range: '~1.2.3',
|
||||
})
|
||||
}).expect('~1.2.3')
|
||||
|
||||
given({
|
||||
kind: 'dev',
|
||||
wantedDependency: 'left-pad',
|
||||
@ -18,24 +17,23 @@ describe('Package json helpers', function () {
|
||||
devDependencies: {},
|
||||
peerDependencies: {},
|
||||
}).expectError('Invalid Parameter')
|
||||
|
||||
given({
|
||||
kind: 'dev',
|
||||
wantedDependency: 'left-pad',
|
||||
dependencies: {},
|
||||
devDependencies: { 'left-pad': '~1.2.3' },
|
||||
peerDependencies: {},
|
||||
}).expect({
|
||||
range: '~1.2.3',
|
||||
})
|
||||
}).expect('~1.2.3')
|
||||
|
||||
given({
|
||||
kind: 'peer',
|
||||
wantedDependency: 'left-pad',
|
||||
dependencies: {},
|
||||
devDependencies: {},
|
||||
peerDependencies: { 'left-pad': '~1.2.3' },
|
||||
}).expect({
|
||||
range: '~1.2.3',
|
||||
})
|
||||
}).expect('~1.2.3')
|
||||
|
||||
given({
|
||||
kind: 'notreal',
|
||||
wantedDependency: 'left-pad',
|
||||
|
Loading…
x
Reference in New Issue
Block a user