Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 1add2c7

Browse files
committed
deprecate: fix scoped package support
PR-URL: #115
1 parent 6f71f41 commit 1add2c7

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

lib/deprecate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ function deprecate (uri, params, cb) {
3838
body: data,
3939
auth: auth
4040
}
41-
this.request(url.resolve(uri, data._id), options, cb)
41+
this.request(uri, options, cb)
4242
}.bind(this))
4343
}

test/deprecate.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,57 @@ test('deprecate a package', function (t) {
155155
}
156156
)
157157
})
158+
159+
test('deprecate a scoped package', function (t) {
160+
server.expect('GET', '/@test%2funderscore?write=true', function (req, res) {
161+
t.equal(req.method, 'GET')
162+
163+
res.json(cache)
164+
})
165+
166+
server.expect('PUT', '/@test%2funderscore', function (req, res) {
167+
t.equal(req.method, 'PUT')
168+
169+
var b = ''
170+
req.setEncoding('utf8')
171+
req.on('data', function (d) {
172+
b += d
173+
})
174+
175+
req.on('end', function () {
176+
var updated = JSON.parse(b)
177+
178+
var undeprecated = [
179+
'1.0.3', '1.0.4', '1.1.0', '1.1.1', '1.1.2', '1.1.3', '1.1.4', '1.1.5', '1.1.6',
180+
'1.1.7', '1.2.0', '1.2.1', '1.2.2', '1.2.3', '1.2.4', '1.3.0', '1.3.1', '1.3.3'
181+
]
182+
for (var i = 0; i < undeprecated.length; i++) {
183+
var current = undeprecated[i]
184+
t.notEqual(
185+
updated.versions[current].deprecated,
186+
MESSAGE,
187+
current + ' not deprecated'
188+
)
189+
}
190+
191+
t.equal(
192+
updated.versions[VERSION].deprecated,
193+
MESSAGE,
194+
VERSION + ' deprecated'
195+
)
196+
res.statusCode = 201
197+
res.json({ deprecated: true })
198+
})
199+
})
200+
201+
client.deprecate(
202+
common.registry + '/@test%2funderscore',
203+
PARAMS,
204+
function (er, data) {
205+
t.ifError(er)
206+
t.ok(data.deprecated, 'was deprecated')
207+
208+
t.end()
209+
}
210+
)
211+
})

0 commit comments

Comments
 (0)