add error if framework is not supported

This commit is contained in:
Jonathan Rainville 2018-10-17 13:50:30 -04:00 committed by Pascal Precht
parent 9ac2dde3eb
commit bae21133bc
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 13 additions and 10 deletions

View File

@ -1,16 +1,16 @@
class Scaffolding {
constructor(engine, _options) {
this.engine = engine;
constructor(embark, _options) {
this.embark = embark;
this.options = _options;
this.plugins = _options.plugins;
engine.events.setCommandHandler("scaffolding:generate:contract", (options, cb) => {
embark.events.setCommandHandler("scaffolding:generate:contract", (options, cb) => {
this.framework = options.contractLanguage;
this.fields = options.fields;
this.generate(options.contract, options.overwrite, true, cb);
});
engine.events.setCommandHandler("scaffolding:generate:ui", (options, cb) => {
embark.events.setCommandHandler("scaffolding:generate:ui", (options, cb) => {
this.framework = options.framework;
this.fields = options.fields;
this.generate(options.contract, options.overwrite, false, cb);
@ -39,6 +39,9 @@ class Scaffolding {
this.plugins.loadInternalPlugin('scaffolding-solidity', this.options);
break;
default:
this.embark.logger.error(__('Selected framework not supported'));
this.embark.logger.error(__('Supported Frameworks are: %s', 'react, solidity'));
process.exit(1);
}
}
@ -47,8 +50,8 @@ class Scaffolding {
const build = this.getScaffoldPlugin(this.framework);
if (!build) {
this.engine.logger.error("Could not find plugin for framework '" + this.framework + "'");
process.exit();
this.embark.logger.error("Could not find plugin for framework '" + this.framework + "'");
process.exit(1);
}
const hasFields = Object.getOwnPropertyNames(this.fields).length !== 0;
@ -66,15 +69,15 @@ class Scaffolding {
try {
build(contract, overwrite, cb);
} catch (err) {
this.engine.logger.error(err.message);
this.embark.logger.error(err.message);
}
} else {
// Contract already exists
this.engine.events.request("contracts:list", (_err, contractsList) => {
this.embark.events.request("contracts:list", (_err, contractsList) => {
if (_err) throw new Error(_err);
const contract = contractsList.find(x => x.className === contractName);
if (!contract) {
this.engine.logger.error("contract '" + contractName + "' does not exist");
this.embark.logger.error("contract '" + contractName + "' does not exist");
cb();
return;
}
@ -82,7 +85,7 @@ class Scaffolding {
try {
build(contract, overwrite, cb);
} catch (err) {
this.engine.logger.error(err.message);
this.embark.logger.error(err.message);
}
});
}