forked from mgechev/angularjs-in-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric-task.js
38 lines (31 loc) · 954 Bytes
/
generic-task.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module.exports = function (gulp, markdownpdf, path, log, chalk, rename, TITLE) {
function genericTask(lang){
gulp.task('generate:pdf:' + lang, function() {
var files = ['./temp/*.md'];
if (lang === 'eng'){
files = './temp/README.md';
}
else if(lang !== 'all'){
files = ['./temp/*-'+lang+'.md'];
}
return gulp.src(files)
.pipe(markdownpdf({
cwd: path.resolve('./temp/'),
layout: 'github'
}))
.on('error', function(err){
log(chalk.red('doc task failed'), err);
})
.pipe(rename(function (path) {
var lang = 'ENG';
if(path.basename.indexOf('-') >= 0){
lang = path.basename.replace('README-', '').toUpperCase();
}
path.basename = TITLE + ' ('+lang+')';
path.extname = '.pdf';
}))
.pipe(gulp.dest('./build/'));
});
}
return genericTask;
};