What does "... paths.js" mean in 'gulp.src ([... paths.js,'! Gulpfile.babel.js '], {base:'. '})'?

I have the following gulp task:

// Compile ES6 to ES5 and copy to dist
gulp.task('babel', () =>
  gulp.src([...paths.js, '!gulpfile.babel.js'], { base: '.' })
    .pipe(plugins.newer('dist'))
    .pipe(plugins.sourcemaps.init())
    .pipe(plugins.babel())
    .pipe(plugins.sourcemaps.write('.', {
      includeContent: false,
      sourceRoot(file) {
        return path.relative(file.path, __dirname);
      }
    }))
    .pipe(gulp.dest('dist'))
);
Run codeHide result

According to the gulp Doc ( gulp.src ), I found out that gulp.src emits files matching the provided glob or globs array.
But I can not understand the meaning of "... paths.js" here. There is no file named "paths.js" in the project directory.

Is there anyone who can help me figure this out?

+4
source share
1 answer

... ES2015 (aka "ES6" ) : (, ) .

:

let a = [1, 2, 3];
let b = [...a, 4, 5];
console.log(b); // 1, 2, 3, 4, 5
Hide result

,

gulp.src([...paths.js, '!gulpfile.babel.js'], { base: '.' })

... paths.js, '!gulpfile.babel.js' src. , paths.js - ; , concat:

gulp.src(paths.js.concat('!gulpfile.babel.js'), { base: '.' })

:

function testing(a, b, c) {
  console.log("a = " + a);
  console.log("b = " + b);
  console.log("c = " + c);
}
let x = [1, 2, 3];
testing(...x);  // Shows:
                // a = 1
                // b = 2
                // c = 3
Hide result
+5

Source: https://habr.com/ru/post/1651879/


All Articles