Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb78535e

Browse files
committed
fix: Returnundefined when no version is found
1 parentddc2f97 commitb78535e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

‎lib/get-last-release.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = async ({publishConfig, name}, logger) => {
1919
constdata=awaitpromisify(client.get.bind(client))(uri,{auth});
2020
if(data&&!data['dist-tags']){
2121
logger.log('No version found of package %s found on %s',name,registry);
22-
return{};
22+
return;
2323
}
2424
constdistTags=data['dist-tags'];
2525
letversion;
@@ -34,7 +34,7 @@ module.exports = async ({publishConfig, name}, logger) => {
3434
}catch(err){
3535
if(err.statusCode===404||/notfound/i.test(err.message)){
3636
logger.log('No version found of package %s found on %s',name,registry);
37-
return{};
37+
return;
3838
}
3939
throwerr;
4040
}

‎test/get-last-release.test.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ test.serial('Get nothing from completely unpublished package name', async t => {
9494
constregistryMock=mock(name).reply(200,unpublishedModule);
9595
constrelease=awaitlastRelease({name,publishConfig:{registry}},t.context.logger);
9696

97-
t.is(release.version,undefined);
97+
t.falsy(release);
9898
t.true(registryMock.isDone());
9999
});
100100

@@ -103,7 +103,7 @@ test.serial('Get nothing from not yet published package name (unavailable)', asy
103103
constregistryMock=mock(name).reply(404,{});
104104
constrelease=awaitlastRelease({name,publishConfig:{registry}},t.context.logger);
105105

106-
t.is(release.version,undefined);
106+
t.falsy(release);
107107
t.true(registryMock.isDone());
108108
});
109109

@@ -112,7 +112,7 @@ test.serial('Get nothing from not yet published package name (unavailable w/o re
112112
constregistryMock=mock(name).reply(404);
113113
constrelease=awaitlastRelease({name,publishConfig:{registry}},t.context.logger);
114114

115-
t.is(release.version,undefined);
115+
t.falsy(release);
116116
t.true(registryMock.isDone());
117117
});
118118

@@ -135,7 +135,7 @@ test.serial('Get nothing from not yet published package name (unavailable w/o st
135135
awaitappendFile('./.npmrc','fetch-retry-factor = 1\nfetch-retry-mintimeout = 1\nfetch-retry-maxtimeout = 1');
136136
constrelease=awaitlastRelease({name,publishConfig:{registry}},t.context.logger);
137137

138-
t.is(release.version,undefined);
138+
t.falsy(release);
139139
t.true(registryMock.isDone());
140140
});
141141

‎test/integration.test.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ test.serial('Return nothing if no version if published', async t => {
9595
awaitwriteJson('./package.json',pkg);
9696
constnextRelease=awaitt.context.m.getLastRelease({},{logger:t.context.logger});
9797

98-
t.deepEqual(nextRelease,{});
98+
t.falsy(nextRelease);
9999
});
100100

101101
test.serial('Return last version published',asynct=>{
@@ -155,7 +155,7 @@ test.serial('Return nothing for an unpublished package', async t => {
155155
awaitexeca('npm',['unpublish','unpublished','--force']);
156156

157157
constnextRelease=awaitt.context.m.getLastRelease({},{logger:t.context.logger});
158-
t.deepEqual(nextRelease,{});
158+
t.falsy(nextRelease);
159159
});
160160

161161
test.serial('Publish a package',asynct=>{
@@ -176,7 +176,7 @@ test.serial('Verify token and set up auth only on the fist call', async t => {
176176
awaitt.notThrows(t.context.m.verifyConditions({},{logger:t.context.logger}));
177177

178178
letnextRelease=awaitt.context.m.getLastRelease({},{logger:t.context.logger});
179-
t.deepEqual(nextRelease,{});
179+
t.falsy(nextRelease);
180180

181181
awaitt.context.m.publish({},{logger:t.context.logger,nextRelease:{version:'1.0.0'}});
182182

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp