Skip to content

is possible overwrite the same file #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Mirodil opened this issue Feb 14, 2014 · 8 comments
Closed

is possible overwrite the same file #267

Mirodil opened this issue Feb 14, 2014 · 8 comments

Comments

@Mirodil
Copy link

Mirodil commented Feb 14, 2014

Hi,
Is possible overwrite the same file? for example

gulp.task('styles', function() {
  return gulp.src('content/**/*.css')
    .pipe(minifyCSS())
    .pipe(gulp.dest('content'));
});
@Mirodil Mirodil closed this as completed Feb 14, 2014
@yocontra
Copy link
Member

yes

@michaelwarren1106
Copy link

so....how?

@juliocanares
Copy link

yes it's possible just add the base parameter

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

@erikwoods
Copy link

gold star for you @juliocanares - worked for me

@mathijspoc
Copy link

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"));

});

@kover
Copy link

kover commented Mar 25, 2017

@mathijspoc

try this

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

@jmsherry
Copy link

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.

@gulpjs gulpjs locked as resolved and limited conversation to collaborators Mar 1, 2018
@yocontra
Copy link
Member

yocontra commented Mar 1, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants