Skip to content

Commit

Permalink
feat(template): Load default template if no custom template is found
Browse files Browse the repository at this point in the history
  • Loading branch information
rafinskipg committed Dec 25, 2016
1 parent 43fdac8 commit 41d5128
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
26 changes: 23 additions & 3 deletions tasks/lib/load-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,37 @@ function readTemplateFile(template, logger) {

fs.readFile(template, 'utf8' ,function (err, data) {
if (err) {
logger('error', 'No template found', err);
dfd.resolve(null);
logger('error', 'No custom template found', err);
loadDefaultTemplate(logger)
.then(dfd.resolve)
.catch(dfd.reject)
}else{
logger('info', 'Found template rc');
logger('info', 'Found template');
dfd.resolve(data);
}
});

return dfd.promise;
}

function loadDefaultTemplate(logger){
return new Promise(function(resolve, reject){

debug('loading default template')

fs.readFile(__dirname +'/../../templates/template.md', 'utf8', function(err, data){
if (err) {
logger('error', 'No default template found', err);
resolve(null);
}else{
logger('info', 'Found default template');
resolve(data);
}
})

})
}


function loadTemplateFile(data) {
this.log('debug','loading template from', this.options.template);
Expand Down
3 changes: 2 additions & 1 deletion tasks/lib/write-change-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function writeChangelog(commits) {
title: module.options.app_name,
version:{
number: module.options.tag,
name: module.options.version_name
name: module.options.version_name,
date: new Date()//Todo get the date of the tag
}
};

Expand Down

0 comments on commit 41d5128

Please sign in to comment.