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/'));
});Written by Ion D. Filho
Related protips
2 Responses
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 + ']';
};
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/'));
});
Have a fresh tip? Share with Coderwall community!
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside