stream-render-pipeline
Version:
File generation strategy for working with creating/modifying files using gulp
66 lines (57 loc) • 1.31 kB
Markdown
File generation strategy for working with creating/modifying files using gulp
```bash
npm i stream-render-pipeline
```
```js
const lazypipe = require('lazypipe');
const gulpPlugins = require('auto-plug')('gulp');
const File = require('stream-render-pipeline');
module.exports = class TextFile extends File
{
construct(opts)
{
super(opts)
}
get render()
{
let {foo} = this.data;
return lazypipe()
.pipe(gulpPlugins.addSrc, this.tplPath(__dirname, '*.txt')) // Template file
.pipe(gulpPlugins.template, {foo}); // Templating
}
}
```
```js
const {dest} = require('gulp');
const inquirer = require('inquirer');
const TextFile = require('./pipes/text');
/**
* Generate text file
*/
module.exports = function text()
{
let defaults = {
foo: 'bar'
};
return inquirer.prompt([
// Questions
]).then(answers => {
let build = {...defaults, ...answers};
new TextFile(build).render().pipe( dest('./src') )
});
}
```
```bash
gulp text
```
- */pipes*
- */presets*
- */questions*
- */templates*