mirror of https://github.com/embarklabs/embark.git
add error if framework is not supported
This commit is contained in:
parent
9ac2dde3eb
commit
bae21133bc
|
@ -1,16 +1,16 @@
|
||||||
class Scaffolding {
|
class Scaffolding {
|
||||||
constructor(engine, _options) {
|
constructor(embark, _options) {
|
||||||
this.engine = engine;
|
this.embark = embark;
|
||||||
this.options = _options;
|
this.options = _options;
|
||||||
this.plugins = _options.plugins;
|
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.framework = options.contractLanguage;
|
||||||
this.fields = options.fields;
|
this.fields = options.fields;
|
||||||
this.generate(options.contract, options.overwrite, true, cb);
|
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.framework = options.framework;
|
||||||
this.fields = options.fields;
|
this.fields = options.fields;
|
||||||
this.generate(options.contract, options.overwrite, false, cb);
|
this.generate(options.contract, options.overwrite, false, cb);
|
||||||
|
@ -39,6 +39,9 @@ class Scaffolding {
|
||||||
this.plugins.loadInternalPlugin('scaffolding-solidity', this.options);
|
this.plugins.loadInternalPlugin('scaffolding-solidity', this.options);
|
||||||
break;
|
break;
|
||||||
default:
|
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);
|
const build = this.getScaffoldPlugin(this.framework);
|
||||||
if (!build) {
|
if (!build) {
|
||||||
this.engine.logger.error("Could not find plugin for framework '" + this.framework + "'");
|
this.embark.logger.error("Could not find plugin for framework '" + this.framework + "'");
|
||||||
process.exit();
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasFields = Object.getOwnPropertyNames(this.fields).length !== 0;
|
const hasFields = Object.getOwnPropertyNames(this.fields).length !== 0;
|
||||||
|
@ -66,15 +69,15 @@ class Scaffolding {
|
||||||
try {
|
try {
|
||||||
build(contract, overwrite, cb);
|
build(contract, overwrite, cb);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.engine.logger.error(err.message);
|
this.embark.logger.error(err.message);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Contract already exists
|
// 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);
|
if (_err) throw new Error(_err);
|
||||||
const contract = contractsList.find(x => x.className === contractName);
|
const contract = contractsList.find(x => x.className === contractName);
|
||||||
if (!contract) {
|
if (!contract) {
|
||||||
this.engine.logger.error("contract '" + contractName + "' does not exist");
|
this.embark.logger.error("contract '" + contractName + "' does not exist");
|
||||||
cb();
|
cb();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +85,7 @@ class Scaffolding {
|
||||||
try {
|
try {
|
||||||
build(contract, overwrite, cb);
|
build(contract, overwrite, cb);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.engine.logger.error(err.message);
|
this.embark.logger.error(err.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue