Skip to content

Commit 5849c15

Browse files
committed
fix: fix npm log
1 parent 2385f55 commit 5849c15

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

lib/package/npm.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,34 +71,47 @@ export default class Npm {
7171
}
7272

7373
async setTags ( { repeatOnError, logger } = {} ) {
74-
logger ||= globalThis.console;
75-
7674
if ( this.pkg.isPrivate ) return result( [ 200, "Package is private" ] );
77-
if ( !this.pkg.name ) return result( [ 500, "Package has no name" ] );
75+
76+
logger ||= globalThis.console;
7877

7978
return repeatAction(
8079
async () => {
81-
const res = await this.#setTags();
80+
var res, error;
81+
82+
if ( !this.pkg.name ) {
83+
res = result( [ 500, "Package has no name" ] );
84+
}
85+
else {
86+
res = await this.#setTags();
87+
88+
error = true;
89+
}
8290

8391
logger.log( "Set npm tags:", res.ok
8492
? ( res.data.updated
8593
? ansi.ok( " Updated " )
8694
: "Not modified" )
8795
: ansi.error( " " + res.statusText + " " ) );
8896

89-
if ( !res.ok ) throw res;
90-
91-
return res;
97+
if ( !res.ok && error ) {
98+
throw res;
99+
}
100+
else {
101+
return res;
102+
}
92103
},
93104
{
94105
repeatOnError,
95106
}
96107
);
97108
}
98109

99-
async setAccessStatus ( accessStatus, { repeatOnError } = {} ) {
110+
async setAccessStatus ( accessStatus, { repeatOnError, logger } = {} ) {
100111
if ( this.pkg.isPrivate ) return result( [ 200, "Package is private" ] );
101112

113+
logger ||= globalThis.console;
114+
102115
return repeatAction(
103116
async () => {
104117
var res, error;
@@ -112,7 +125,7 @@ export default class Npm {
112125
error = true;
113126
}
114127

115-
console.log( `Set npm access status for "${ this.pkg.name }":`, res + "" );
128+
logger.log( "Set npm access status:", res + "" );
116129

117130
if ( !res.ok && error ) {
118131
throw res;

0 commit comments

Comments
 (0)