Last Updated: July 25, 2019
·
64.54K
· iondrimba

Simple Gulp Copy file task

This is just a handy way of copying a file from one folder to another.
There is no goal of replacing other tools out there.
No extra lib or package needed.

gulp.task('copy', function () {
    gulp.src('./src/templates/index.html')
        .pipe(gulp.dest('./public/'));
});

2 Responses
Add your response

I use:

// copyTo.js v1
function copyTo(files, dest) {
if (typeof files == 'string') {
files = [files];
};
gulp.src(files).pipe(gulp.dest(dest));
console.log(cliDate() + ' copyTo success');
};

// cliDate.js v1
function cliDate() {
let date = new Date(),
hours = date.getHours(),
minutes = date.getMinutes(),
seconds = date.getSeconds();
hours < 10 ? hours = '0' + hours : hours;
minutes < 10 ? minutes = '0' + minutes : minutes;
seconds < 10 ? seconds = '0' + seconds : seconds;
return '[' + hours + ':' + minutes + ':' + seconds + ']';
};

over 1 year ago ·

You can also use globs to match directories and files:


gulp.task('vendor', function () {
return gulp
.src([
'./nodemodules/bootstrap/dist/',
'./nodemodules/intl/dist/
'
], { base: 'nodemodules' })
.pipe(gulp.dest('./vendor/'));
});
over 1 year ago ·
  NODES
Community 1
iOS 3
Javascript 10
mac 1
node.js 1
os 6