Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp.src does not consider base directory

I have following stucture of the project:

- _build/
- build-tools/
  - gulpfile.js
- someFolder/
- excludeFolder/
- index.html

I want to copy all the files except _build and 'excludeFolder' dir to the _build/release directory.

I am using this gulp task:

gulp.src(['*',
          '!_build/**/*',
          '!build-tools/**/*',
          '!excludeFolder/**/*'],{base:'..'})
        .pipe(gulp.dest('_build/release'));

How can I command Gulp to start relative path from upper root directory, or any other directory that the gulfile.js is located?

like image 211
Ondřej Severa Avatar asked Mar 17 '23 15:03

Ondřej Severa


1 Answers

As far as I understand the behavior your looking is cwd, not base

    gulp.src([
      '**',
      '!_build',
      '!_build/**',
      '!build-tools',
      '!build-tools/**',
      '!excludeFolder',
      '!excludeFolder/**'
    ],{ cwd:'..' })
    .pipe(gulp.dest('_build/release'), { cwd: '..' });

base is a tricky property, which aims to say to gulp where to start copying the files based on the cwd, but that doesn't mean that you can omit the parent folder .. call on gulp.src (your case specifically).

like image 185
Rigotti Avatar answered Mar 28 '23 20:03

Rigotti