-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathgulp.js
35 lines (29 loc) · 1.15 KB
/
gulp.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
'use strict';
const Panini = require('.');
/**
* Create a cached instance of Panini. The first time this function is called, it will create an instance of Panini and return the stream transform function. On subsequent calls, the cached instance's stream transform function will be returned.
* @returns {PaniniStreamFunction} Panini transform stream function.
*/
const create = () => {
let panini;
/**
* Compile a Panini project located at `src`.
* @param {String} src - Input folder.
* @param {Object} [opts] - Panini options. These will override any settings in `package.json`.
* @returns {Object} Stream compile function.
*/
return (src, opts) => {
if (!panini) {
panini = new Panini(src, null, opts).panini;
panini.refresh();
}
const stream = panini.compile();
// This lil guy is mostly used for testing, so we can inspect the underlying Panini instance
stream._panini = panini;
return stream;
};
};
// This is the main way Panini is used with Gulp
module.exports = create();
// If you need multiple instances of Panini in one Gulpfile, this function can be used instead
module.exports.create = create;