From fdb2d4aed33d5beb8f4fa967457b3c4dd1c0cb02 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Tue, 15 May 2018 16:19:39 -0400 Subject: [PATCH] Changes based on code review - Style changes for not requiring "else" in handlebar helpers - Changed build to async --- lib/cmds/scaffolding.js | 3 +-- lib/modules/scaffolding-react/index.js | 20 ++++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/cmds/scaffolding.js b/lib/cmds/scaffolding.js index 57d8ea860..c7eae44c6 100644 --- a/lib/cmds/scaffolding.js +++ b/lib/cmds/scaffolding.js @@ -34,8 +34,7 @@ class Scaffolding { } const contract = contractConfiguration.contracts[contractName]; - const result = build(contract); - this.embark.logger.info(result); + build(contract); } } diff --git a/lib/modules/scaffolding-react/index.js b/lib/modules/scaffolding-react/index.js index af125c72f..5522c0193 100644 --- a/lib/modules/scaffolding-react/index.js +++ b/lib/modules/scaffolding-react/index.js @@ -10,25 +10,22 @@ Handlebars.registerHelper('ifview', function(stateMutability, options) { let result = stateMutability == 'view' || stateMutability == 'pure' || stateMutability == 'constant'; if (result) { return options.fn(this); - } else { - return options.inverse(this); - } + } + return options.inverse(this); }); Handlebars.registerHelper('ifeq', function(elem, value, options){ if (elem == value) { return options.fn(this); - } else { - return options.inverse(this); } + return options.inverse(this); }); Handlebars.registerHelper('iflengthgt', function(arr, val, options) { if (arr.length > val) { return options.fn(this); - } else { - return options.inverse(this); - } + } + return options.inverse(this); }); Handlebars.registerHelper('emptyname', function(name, index) { @@ -40,9 +37,8 @@ Handlebars.registerHelper('methodname', function(abiDefinition, functionName, in let funCount = abiDefinition.filter(x => x.name == functionName).length; if(funCount == 1){ return '.' + functionName; - } else { - return new Handlebars.SafeString(`['${functionName}(${inputs !== null ? inputs.map(input => input.type).join(',') : '' })']`); } + return new Handlebars.SafeString(`['${functionName}(${inputs !== null ? inputs.map(input => input.type).join(',') : ''})']`); }); class ScaffoldingReact { @@ -78,7 +74,7 @@ class ScaffoldingReact { }); } - build(contract){ + async build(contract){ this._buildHTML(contract); const filename = contract.className.toLowerCase(); @@ -98,7 +94,7 @@ class ScaffoldingReact { fs.writeFileSync("./embark.json", JSON.stringify(embarkJson, null, 4)); - return filename + ".html generated"; + this.embark.logger.info(filename + ".html generated"); } }