calc a <major>.<minor> branch for unqualified template names

doesn't calc a branch if a url/shortcut is supplied that hostedGitInfo knows
how to parse

only does this for unqualified names if a committish isn't supplied, i.e.
doesn't override '#develop' in 'typescript#develop'
This commit is contained in:
Michael Bradley, Jr 2018-10-10 11:18:36 -05:00 committed by Pascal Precht
parent d50ae8c649
commit cc08a16ae3
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,7 @@
let fs = require('../core/fs.js'); let fs = require('../core/fs.js');
let hostedGitInfo = require('hosted-git-info'); let hostedGitInfo = require('hosted-git-info');
let utils = require('./utils.js'); let utils = require('./utils.js');
let semver = require('semver');
class TemplateGenerator { class TemplateGenerator {
constructor(templateName) { constructor(templateName) {
@ -104,6 +105,10 @@ class TemplateGenerator {
hgi = hostedGitInfo.fromUrl(uri); hgi = hostedGitInfo.fromUrl(uri);
if (!hgi || hgi.user.includes('#')) { if (!hgi || hgi.user.includes('#')) {
let templateAndBranch = uri.split('#'); let templateAndBranch = uri.split('#');
if (templateAndBranch.length === 1) {
let embarkVersion = semver(require('../../package.json').version);
templateAndBranch.push(`${embarkVersion.major}.${embarkVersion.minor}`);
}
templateAndBranch[0] = `embark-framework/embark-${templateAndBranch[0]}-template`; templateAndBranch[0] = `embark-framework/embark-${templateAndBranch[0]}-template`;
hgi = hostedGitInfo.fromUrl(templateAndBranch.join('#')); hgi = hostedGitInfo.fromUrl(templateAndBranch.join('#'));
} }