-1

I have to do a gulp task to read the data from a file and write it into another file.

for which i am doing :

    var gulp = require('gulp');
     var fs = require('fs');
    gulp.task('readFile', function() {
    return gulp.src('app/dataConfog.json')
        .pipe(fs.readFile("app/dataConfog.json",  function(err, data){
            fs.writeFile('app/scripts/apiConfig.js', data);
        }))
        .pipe(gulp.dest('./dest/'))
})

but i am getting the following error:

enter image description here

Any help would be appreciated

a better oliver
  • 26,330
  • 2
  • 58
  • 66
swathi anupuram
  • 795
  • 1
  • 7
  • 14
  • Possible duplicate of [Gulp - copy and rename a file](http://stackoverflow.com/questions/28593660/gulp-copy-and-rename-a-file) – Sven Schoenung Nov 10 '16 at 08:56
  • @SvenSchoenung I dont want to copy whole file i just need to read a file and take the data and from that data(array of objects in my case) i just need only object and write that object into another file – swathi anupuram Nov 10 '16 at 08:59
  • Then why didn't you say that in your question? Edit it and explain exactly what you're trying to do. – Sven Schoenung Nov 10 '16 at 09:02

1 Answers1

-1

try using this

var fs = require("fs");

gulp.task('doSometing', function() {

  return gulp.src(dirs.src + '/templates/*.html')
    .pipe(fs.readFile("path/to/file.something", "utf-8", function(err, _data) {
      //do something with your data
    }))
   .pipe(gulp.dest('destination/path'));
  });
Sujithrao
  • 789
  • 3
  • 12
  • 27