Gulp: is possible overwrite the same file

Created on 14 Feb 2014  路  8Comments  路  Source: gulpjs/gulp

Hi,
Is possible overwrite the same file? for example

gulp.task('styles', function() {
  return gulp.src('content/**/*.css')
    .pipe(minifyCSS())
    .pipe(gulp.dest('content'));
});

Most helpful comment

yes it's possible just add the base parameter

  gulp.src('./app/**/*.js', {base: './'})
        .pipe(prettify())
        .pipe(gulp.dest('./'));

All 8 comments

yes

so....how?

yes it's possible just add the base parameter

  gulp.src('./app/**/*.js', {base: './'})
        .pipe(prettify())
        .pipe(gulp.dest('./'));

gold star for you @juliocanares - worked for me

not working for me..

var revReplace = require("gulp-rev-replace");
gulp.task("revrep", function(){
var manifest = gulp.src('./assets/js/rev-manifest.json');

return gulp.src("./index.html", {base: "./"})
    .pipe(revReplace({manifest: manifest}))
    .pipe(gulp.dest("./index.html"));

});

@mathijspoc

try this

return gulp.src("./index.html", {base: "./"}) .pipe(revReplace({manifest: manifest})) .pipe(gulp.dest("./"));

Sounds dumb, but always check your write permissions on the file. If files are owned by root user then you may need to change that or sudo in order to overwrite.

Just to be clear - the original ticket was asking "is it possible to overwrite a file" and pasted code. Yes, it is possible to overwrite a file - and yes, the code you pasted will work fine. For anyone still stumbling on this ticket - you don't have to do anything special to overwrite files. The code in the original ticket works fine - so yes.

You only need the base parameter if you're trying to overwrite an input file with the same file from the same pipeline (like you just want to transform some files in a folder and replace them with the transformed ones). base: '.' will do that just fine, it tells gulp to do everything relative to the root directory so it will replace nested files in folders.

Was this page helpful?
0 / 5 - 0 ratings