-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
132 lines (118 loc) · 2.75 KB
/
gulpfile.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
'use strict';
/**
* @fileOverview Testing
* @author Oleg Dutchenko <[email protected]>
* @version 1.0.0
*/
// ----------------------------------------
// Imports
// ----------------------------------------
// modules
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const argv = require('yargs').argv;
const del = require('del');
const jsdoc = require('gulp-jsdoc3');
// plugin
const ejsMonster = require('./index');
// ----------------------------------------
// Private
// ----------------------------------------
/**
* Debugging flag
* @const {boolean}
* @private
*/
const debugFlag = !!argv.debug;
/**
* Production flag
* @const {boolean}
* @private
*/
const prodFlag = !!argv.p || !!argv.production;
/**
* Plugin user options
* @const {Object}
* @private
*/
const ejsOptions = {
beautify: prodFlag,
showHistory: true,
layouts: './examples/src/_layouts',
widgets: './examples/src/_widgets',
includes: './examples/src/_includes',
requires: './examples/src/_requires',
compileDebug: debugFlag,
delimiter: '%',
localsName: 'locals',
locals: {
customProp: 'customProp'
}
};
// ----------------------------------------
// Tasks
// ----------------------------------------
gulp.task('ejs', function () {
return gulp.src('./examples/src/*.ejs')
.pipe(ejsMonster(ejsOptions).on('error', ejsMonster.preventCrash))
.pipe(gulp.dest('./examples/dist/'));
});
gulp.task('watch', gulp.series('ejs', function () {
gulp.watch('./examples/src/*.ejs', gulp.series('ejs'));
}));
gulp.task('docs', gulp.series(function () {
return del('./docs/');
}, function () {
let jsdocConfig = {
source: {
includePattern: '.+\\.js(docs|x)?$',
excludePattern: '(^|\\/|\\\\)_'
},
tags: {
allowUnknownTags: true,
dictionaries: [
'jsdoc',
'closure'
]
},
opts: {
destination: './docs/',
verbose: false,
encoding: 'utf8',
template: './node_modules/jsdoc-simple-theme/',
recurse: true
},
plugins: [
'plugins/markdown',
'./node_modules/jsdoc-export-default-interop/dist/index',
'./node_modules/jsdoc-ignore-code/index',
'./node_modules/jsdoc-sourcecode-tag/index'
],
markdown: {
parser: 'gfm',
hardwrap: true
},
templates: {
cleverLinks: false,
monospaceLinks: false,
systemName: 'locals API',
default: {
outputSourceFiles: true,
layoutFile: './node_modules/jsdoc-simple-theme/tmpl/layout.tmpl'
}
}
};
return gulp.src(['./index.js', './methods/**/*.js', './utils/**/*.js'], {buffer: false})
.pipe(jsdoc(jsdocConfig, function () {
console.log('done');
}));
}));
gulp.task('test-setup-options', function () {
return gulp.src('./tests/setup-options.js', {read: false})
.pipe(mocha({
reporter: 'spec'
}))
.once('error', () => {
process.exit(1);
});
});