Skip to content

Commit

Permalink
fix: better handling of await calls
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Feb 7, 2020
1 parent 69aa9ac commit bc3abd5
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/commands/init.ts
Expand Up @@ -48,7 +48,7 @@ module.exports = async function(options?: HexaInitOptions) {
const subscriptions: AzureSubscription[] = Config.get("subscriptions");

if (!subscriptions || (subscriptions && subscriptions.length === 0) || process.env.HEXA_FORCE_LOGIN) {
await require(`./login`)();
await (require(`./login`))();
} else {
debug(`found subscriptions ${chalk.green(JSON.stringify(subscriptions))}`);
}
Expand Down
6 changes: 3 additions & 3 deletions src/features/container-registry/index.ts
Expand Up @@ -27,7 +27,7 @@ module.exports = async function() {

if (acrList.length === 0) {
// no ACR accout found, create one
return await require(`./create`)("AUTOMATIC");
return await (require(`./create`))("AUTOMATIC");
}

if (creationMode === "AUTOMATIC") {
Expand All @@ -43,7 +43,7 @@ module.exports = async function() {
selectedAcrId = acr.id;
} else {
// we founf one cluster but it was not created by Hexa, go ahead and automatically create one
return (await require(`./create`))("AUTOMATIC");
return await (require(`./create`))("AUTOMATIC");
}
} else if (Array.isArray(acrList)) {
// we found many ACR accounts, let the user choose the right one
Expand All @@ -55,7 +55,7 @@ module.exports = async function() {

if (selectedAcrId === "MANUAL") {
// the user expliticitly chooses to manually create a ACR account
return (await require(`./create`))("MANUAL");
return await (require(`./create`))("MANUAL");
}

const { id, name, hostname } = acrList.find((acr: AzureContainerRegistry) => acr.id === selectedAcrId) as AzureContainerRegistry;
Expand Down
2 changes: 1 addition & 1 deletion src/features/functions/index.ts
Expand Up @@ -52,5 +52,5 @@ module.exports = async function() {
});

// init functions projects
return (await require("./init"))();
return await (require("./init"))();
};
6 changes: 3 additions & 3 deletions src/features/resource-group/index.ts
Expand Up @@ -3,7 +3,7 @@ import { az, Config, saveWorkspace } from "../../core/utils";

module.exports = async function() {
if (process.env.HEXA_AUTO_MODE) {
return (await require(`./create`))("AUTOMATIC");
return await (require(`./create`))("AUTOMATIC");
}

// https://docs.microsoft.com/en-us/cli/azure/group?view=azure-cli-latest#az-group-list
Expand All @@ -17,7 +17,7 @@ module.exports = async function() {

if (selectedResourceId === "MANUAL") {
// create a new resource group
return (await require(`./create`))(selectedResourceId);
return await (require(`./create`))(selectedResourceId);
} else {
const { id, name, location } = resourceGroupsList.find(
(resourceGroup: AzureResourceGroup) => resourceGroup.id === (selectedResourceId as string)
Expand All @@ -36,6 +36,6 @@ module.exports = async function() {
} else {
// no resource found
// create a new resource group
return (await require(`./create`))("AUTOMATIC");
return await (require(`./create`))("AUTOMATIC");
}
};
2 changes: 1 addition & 1 deletion src/features/storage/create.ts
Expand Up @@ -34,5 +34,5 @@ module.exports = async function(creationMode: CreationMode) {
storage
});

return (await require("./tokens"))();
return await (require("./tokens"))();
};
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -27,7 +27,7 @@ let debug: Function;
.filter(feat => feat);
}

return (await require(`./commands/${commandName}`))(options);
return await (require(`./commands/${commandName}`))(options);
} catch (error) {
console.error(chalk.red(`Command "${commandName}" not supported yet.`));
console.error(chalk.red(error));
Expand Down

0 comments on commit bc3abd5

Please sign in to comment.