hparra / gulp-rename

Rename files easily
MIT License
692 stars 73 forks source link

Why dirname is always '.'? #40

Closed rootical closed 9 years ago

rootical commented 9 years ago
gulp.src(['client/README.md'])
        .pipe($.rename(function(path){
               console.log(path); // { dirname: '.', basename: 'README', extname: '.md' }
        }));

I want to know the name of the directory. Why is it always equal to '.'? Any way to get it correctly?

shinnn commented 9 years ago

No, dirname is not always .. Check the readme:

dirname is the relative path from the base directory set by gulp.src to the filename.

gulp.src(['client/README.md']) sets base path to client/.

var gulp = require('gulp');

gulp.src(['client/README.md'])
.on('data', function(file) {
  console.log(file.base); // /User/path/to/project/client/
});