Skip to content

Commit 89e3eb6

Browse files
santteegtiurimatias
authored andcommitted
feat(@embark/cli): add --template option to embark demo cli command
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
1 parent 58795ca commit 89e3eb6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cmd/cmd.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,19 @@ class Cmd {
9292
program
9393
.command('demo')
9494
.option('--locale [locale]', __('language to use (default: en)'))
95+
.option('--template <name/url>', __('download a demo template using a known name or a git host URL'))
9596
.description(__('create a working dapp with a SimpleStorage contract'))
9697
.action(function(options) {
9798
i18n.setOrDetectLocale(options.locale);
98-
embark.generateTemplate('demo', './', 'embark_demo');
99+
if(options.template) {
100+
const hostedGitInfo = require('hosted-git-info');
101+
const hgi = hostedGitInfo.fromUrl(options.template);
102+
const url = !hgi ? `embark-framework/embark-${options.template}-template#demo`:options.template;
103+
const folderName = !hgi ? `embark_${options.template}_demo`:'template_demo';
104+
embark.generateTemplate('demo', './', folderName, url);
105+
} else {
106+
embark.generateTemplate('demo', './', 'embark_demo');
107+
}
99108
});
100109
}
101110

0 commit comments

Comments
 (0)