Skip to content

Commit

Permalink
nit: final cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Primajin committed Feb 19, 2022
1 parent 13cafc5 commit f71f2ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/lib/filterAndReject.ts
@@ -1,7 +1,7 @@
import _ from 'lodash'
import { and } from 'fp-and-or'
import minimatch from 'minimatch'
import semverutils, { SemVer } from 'semver-utils'
import { SemVer, parseRange } from 'semver-utils'
import { FilterRejectPattern, Maybe, VersionSpec } from '../types'

/**
Expand Down Expand Up @@ -44,7 +44,7 @@ function composeFilter(filterPattern: FilterRejectPattern): (name: string, versi
}
// function
else if (typeof filterPattern === 'function') {
predicate = (dependencyName: string, versionSpec: string) => filterPattern(dependencyName, semverutils.parseRange(versionSpec ?? dependencyName))
predicate = (dependencyName: string, versionSpec: string) => filterPattern(dependencyName, parseRange(versionSpec ?? dependencyName))
}
else {
throw new TypeError('Invalid filter. Must be a RegExp, array, or comma-or-space-delimited list.')
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Expand Up @@ -25,7 +25,7 @@ export type Version = string
export type VersionSpec = string
export type VersionLevel = 'major' | 'minor' | 'patch'

export type FilterFunction = (packageName: string, version: SemVer[]) => boolean
type FilterFunction = (packageName: string, version: SemVer[]) => boolean
export type FilterRejectPattern = string | string[] | RegExp | RegExp[] | FilterFunction

export interface Packument {
Expand Down
12 changes: 6 additions & 6 deletions test/getCurrentDependencies.test.ts
Expand Up @@ -154,7 +154,7 @@ describe('getCurrentDependencies', () => {
mocha: '1.2',
moment: '^1.0.0',
chalk: '^1.1.0',
bluebird: '^1.0.0',
bluebird: '^1.0.0'
})
})
})
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('getCurrentDependencies', () => {
mocha: '1.2',
moment: '^1.0.0',
chalk: '^1.1.0',
bluebird: '^1.0.0',
bluebird: '^1.0.0'
})
})
})
Expand Down Expand Up @@ -289,18 +289,18 @@ describe('getCurrentDependencies', () => {
getCurrentDependencies(deps, { rejectVersion: '^1.0.0' }).should.eql({
mocha: '1.2',
lodash: '^3.9.3',
chalk: '^1.1.0',
chalk: '^1.1.0'
})
})

it('reject dependencies by multiple versions (comma-or-space-delimited)', () => {
getCurrentDependencies(deps, { rejectVersion: '^1.0.0,^1.1.0' }).should.eql({
mocha: '1.2',
lodash: '^3.9.3',
lodash: '^3.9.3'
})
getCurrentDependencies(deps, { rejectVersion: '^1.0.0 ^1.1.0' }).should.eql({
mocha: '1.2',
lodash: '^3.9.3',
lodash: '^3.9.3'
})
})

Expand All @@ -311,7 +311,7 @@ describe('getCurrentDependencies', () => {
})
getCurrentDependencies(deps, { rejectVersion: /^\^1/ }).should.eql({
mocha: '1.2',
lodash: '^3.9.3',
lodash: '^3.9.3'
})
})

Expand Down

0 comments on commit f71f2ab

Please sign in to comment.