10

I have gulp task to copy js files

This doesn't work

gulp.src('./**/*.js', {base: '../src/main/'})
    .pipe(gulp.dest('../target/dist'));

This works:

gulp.src('../src/main/**/*.js', {base: '../src/main/'})
        .pipe(gulp.dest('../target/dist'));

So whats the use of base here ? if i have to put whole path in first param, why should i use base ?

is there any official documentation about gulp src ? is it worth using gulp over grunt with limited documentation ?

[UPDATE BASED ON COMMENT]
Why am i using base ?

Please read this Looking for way to copy files in gulp and rename based on parent directory

and moreoever gulp.src can take array of paths so i would need base.

Community
  • 1
  • 1
Venkat Reddy
  • 1,046
  • 1
  • 8
  • 13
  • Why are you using `base` in the first place? It's not in the docs because it's not used except in special circumstances. `gulp.src` is in the [API docs](https://github.com/gulpjs/gulp/blob/master/docs/API.md), `base` is [documented via `glob-stream`](https://github.com/wearefractal/glob-stream#options). – OverZealous Mar 27 '14 at 02:25

2 Answers2

21

The use of .src() is documented on the vinyl-fs github repo: https://github.com/wearefractal/vinyl-fs

The base property is used to determine the file names when saving in .dest().

I think you need to set the current working directory:

gulp
  .src('./**/*.js', {cwd: '../src/main/'})
  .pipe(gulp.dest('../target/dist'))
;
tim-montague
  • 16,217
  • 5
  • 62
  • 51
-3

You should try to use 'root' param instead:

 gulp.src('./**/*.js', {root: '../src/main/'})
     .pipe(gulp.dest('../target/dist'));
Nico Toub
  • 1,528
  • 15
  • 17