gulp-eval

1.0.0 • Public • Published

gulp-eval

Require CommonJS modules, JSON files or files with JS-expression inside gulp tasks with ease.

NPM version Build Status Coverage Status Dependency Status

gulp-eval fills data property of Vinyl objects.

Usage example:

var gulp = require('gulp');
var concat = require('gulp-concat');
var gulpEval = require('gulp-eval');
var through = require('through2');
 
gulp.task('default', () =>
  gulp.src('node_modules/*/package.json')
    .pipe(gulpEval())
    .pipe(through.obj(function(file, enc, next) {
      var data = file.data; // Here we have evaluated package.json
      file.contents = new Buffer(data.name + '#' + data.version);
      next(null, file);
    }))
    .pipe(concat('packages.txt'))
    .pipe(gulp.dest('dest/'))
);

Context

You can provide some like-a-global variables into gulp-eval

var gulpEval = require('gulp-eval');
var globalVar = 42;
var transformStream = gulpEval({globalVar: globalVar});
 
// globalVar will be in context of evaluated code
 

Readme

Keywords

Package Sidebar

Install

npm i gulp-eval

Weekly Downloads

91

Version

1.0.0

License

MIT

Last publish

Collaborators

  • blond
  • qfox
  • yeti-or