Skip to content

Commit

Permalink
feat(@embark/cli): add --template option to embark demo cli command
Browse files Browse the repository at this point in the history
Adds a --template option to the embark demo cli command so it is now possible to generate a demo project using an existing embark's template repository on Github with an existing demo branch (e.g. embark demo --template vue will use embark-framework/embark-vue-template#demo), or any other git URL repository. If no --template option is specified, the command  will generate a demo from default template in templates/demo
  • Loading branch information
santteegt authored and iurimatias committed Nov 18, 2018
1 parent 58795ca commit 89e3eb6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cmd/cmd.js
Expand Up @@ -92,10 +92,19 @@ class Cmd {
program
.command('demo')
.option('--locale [locale]', __('language to use (default: en)'))
.option('--template <name/url>', __('download a demo template using a known name or a git host URL'))
.description(__('create a working dapp with a SimpleStorage contract'))
.action(function(options) {
i18n.setOrDetectLocale(options.locale);
embark.generateTemplate('demo', './', 'embark_demo');
if(options.template) {
const hostedGitInfo = require('hosted-git-info');
const hgi = hostedGitInfo.fromUrl(options.template);
const url = !hgi ? `embark-framework/embark-${options.template}-template#demo`:options.template;
const folderName = !hgi ? `embark_${options.template}_demo`:'template_demo';
embark.generateTemplate('demo', './', folderName, url);
} else {
embark.generateTemplate('demo', './', 'embark_demo');
}
});
}

Expand Down

0 comments on commit 89e3eb6

Please sign in to comment.