Skip to content

Commit fbdc27d

Browse files
committed
fix(@schematics/update): ensure auth config options are typed properly
1 parent 0126721 commit fbdc27d

File tree

1 file changed

+17
-6
lines changed
  • packages/schematics/update/update

1 file changed

+17
-6
lines changed

packages/schematics/update/update/npm.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ export function getNpmPackageJson(
135135
getNpmConfigOption('https-proxy'),
136136
getNpmConfigOption('strict-ssl'),
137137
getNpmConfigOption('cafile'),
138-
getNpmConfigOption('_auth', registryKey, true),
139-
getNpmConfigOption('_authToken', registryKey, true),
138+
getNpmConfigOption('_auth'),
139+
getNpmConfigOption('_authToken', registryKey),
140140
getNpmConfigOption('username', registryKey, true),
141141
getNpmConfigOption('password', registryKey, true),
142142
getNpmConfigOption('alwaysAuth', registryKey, true),
@@ -159,13 +159,24 @@ export function getNpmPackageJson(
159159

160160
const sslOptions = getNpmClientSslOptions(strictSsl, cafile);
161161

162-
let auth;
162+
const auth: {
163+
token?: string,
164+
alwaysAuth?: boolean;
165+
username?: string;
166+
password?: string
167+
} = {};
168+
169+
if (alwaysAuth !== undefined) {
170+
auth.alwaysAuth = alwaysAuth === 'false' ? false : !!alwaysAuth;
171+
}
172+
163173
if (authToken) {
164-
auth = { token: authToken, alwaysAuth };
174+
auth.token = authToken;
165175
} else if (token) {
166-
auth = { token, alwaysAuth };
176+
auth.token = token;
167177
} else if (username) {
168-
auth = { username, password, alwaysAuth };
178+
auth.username = username;
179+
auth.password = password;
169180
}
170181

171182
const client = new RegistryClient({

0 commit comments

Comments
 (0)