Skip to content

Commit

Permalink
fix: template generation failing
Browse files Browse the repository at this point in the history
  • Loading branch information
Amzani committed May 15, 2024
1 parent 8a428e6 commit 11c27a1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/commands/generate/fromTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class Template extends Command {
output = parsedArgs.output;
}

const parsedFlags = this.parseFlags(flags['disable-hook'], flags['param'], flags['map-base-url'],flags['registry.url'],flags['registry.auth'],flags['registry.token']);
const parsedFlags = this.parseFlags(flags['disable-hook'], flags['param'], flags['map-base-url'], flags['registry.url'], flags['registry.auth'], flags['registry.token']);
const options = {
forceWrite: flags['force-write'],
install: flags.install,
Expand Down Expand Up @@ -245,9 +245,14 @@ export default class Template extends Command {
}
}
private async registryValidation(registryUrl?:string, registryAuth?:string, registryToken?:string) {
const response= await fetch(registryUrl as string);
if (response.status === 401&&!registryAuth&&!registryToken) {
throw new Error('Need to pass either registryAuth in username:password encoded in Base64 or need to pass registryToken');
if (!registryUrl) { return; }
try {
const response = await fetch(registryUrl as string);
if (response.status === 401 && !registryAuth && !registryToken) {
this.error('You Need to pass either registryAuth in username:password encoded in Base64 or need to pass registryToken', { exit: 1 });
}
} catch (error: any) {
this.error(`Can't fetch registryURL: ${registryUrl}`, { exit: 1 });
}
}
private paramParser(inputs?: string[]) {
Expand Down

0 comments on commit 11c27a1

Please sign in to comment.