Skip to content

Commit c24fed2

Browse files
committed
fix: remove figgy pudding
Just take a plain old JavaScript object as an argument
1 parent 3c8cb5d commit c24fed2

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

index.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
'use strict'
22

3-
const figgyPudding = require('figgy-pudding')
43
const npa = require('npm-package-arg')
54
const semver = require('semver')
65

7-
const PickerOpts = figgyPudding({
8-
defaultTag: { default: 'latest' },
9-
enjoyBy: {},
10-
includeDeprecated: { default: false }
11-
})
12-
136
module.exports = pickManifest
14-
function pickManifest (packument, wanted, opts) {
15-
opts = PickerOpts(opts)
16-
const time = opts.enjoyBy && packument.time && +(new Date(opts.enjoyBy))
7+
function pickManifest (packument, wanted, opts = {}) {
8+
const {
9+
defaultTag = 'latest',
10+
enjoyBy = null,
11+
includeDeprecated = false
12+
} = opts
13+
14+
const time = enjoyBy && packument.time && +(new Date(enjoyBy))
1715
const spec = npa.resolve(packument.name, wanted)
1816
const type = spec.type
1917
if (type === 'version' || type === 'range') {
@@ -54,7 +52,7 @@ function pickManifest (packument, wanted, opts) {
5452
throw new Error('Only tag, version, and range are supported')
5553
}
5654

57-
const tagVersion = distTags[opts.defaultTag]
55+
const tagVersion = distTags[defaultTag]
5856

5957
if (
6058
!target &&
@@ -66,7 +64,7 @@ function pickManifest (packument, wanted, opts) {
6664
target = tagVersion
6765
}
6866

69-
if (!target && !opts.includeDeprecated) {
67+
if (!target && !includeDeprecated) {
7068
const undeprecated = versions.filter(v => !packument.versions[v].deprecated && enjoyableBy(v)
7169
)
7270
target = semver.maxSatisfying(undeprecated, wanted, true)
@@ -108,9 +106,9 @@ function pickManifest (packument, wanted, opts) {
108106
// Check if target is forbidden
109107
const isForbidden = target && policyRestrictions && policyRestrictions.versions[target]
110108
const pckg = `${packument.name}@${wanted}${
111-
opts.enjoyBy
109+
enjoyBy
112110
? ` with an Enjoy By date of ${
113-
new Date(opts.enjoyBy).toLocaleString()
111+
new Date(enjoyBy).toLocaleString()
114112
}. Maybe try a different date?`
115113
: ''
116114
}`
@@ -128,7 +126,7 @@ function pickManifest (packument, wanted, opts) {
128126
err.wanted = wanted
129127
err.versions = versions
130128
err.distTags = distTags
131-
err.defaultTag = opts.defaultTag
129+
err.defaultTag = defaultTag
132130
throw err
133131
} else {
134132
return manifest

0 commit comments

Comments
 (0)