I´m trying to copy some files between folders without success.
This is my program:
const gulp = require('gulp');
const using = require('gulp-using')
const fs = require('fs');
const gzip = require('gulp-gzip');
const flatmap = require('gulp-flatmap');
const path = require('path');
const htmlmin = require('gulp-htmlmin');
const cssmin = require('gulp-cssmin');
const uglify = require('gulp-uglify');
const pump = require('pump');
const imagemin = require('gulp-imagemin-changba');
const gulpCopy = require('gulp-copy');
exports.default = function() {
return gulp.src('../front/assets/img/*.*', {encoding: false})
.pipe(gulp.dest('./dist'));
}
If I run a gulp on the terminal I get the following error:
[09:14:07] Using gulpfile ~DesktopESP32 Config ToolswebBuildergulpfile.js
[09:14:07] Starting 'default'...
[09:14:07] The following tasks did not complete: default
Did you forget to signal async completion?`
When I change the function to async as below, it runs but no files are copied.
exports.default = async function() {
return gulp.src('../front/assets/img/*.*', {encoding: false})
.pipe(gulp.dest('./dist'));
}
[09:22:08] Using gulpfile ~DesktopwebBuildergulpfile.js
[09:22:08] Starting 'default'...
[09:22:08] Finished 'default' after 11 ms
If I change the src to copy only one file (by name), it works with or without async and copies the file from the src to the destination
exports.default = function() {
return gulp.src('../front/assets/img/logo.png', {encoding: false})
.pipe(gulp.dest('./dist'));
}`
result:
[09:23:36] Using gulpfile ~DesktopwebBuildergulpfile.js
[09:23:36] Starting 'default'...
[09:23:36] Finished 'default' after 26 ms
exports.default = async function() {
return gulp.src('../front/assets/img/favicon.png', {encoding: false})
.pipe(gulp.dest('./dist'));
}
[09:24:52] Using gulpfile ~DesktopwebBuildergulpfile.js
[09:24:52] Starting 'default'...
[09:24:52] Finished 'default' after 10 ms`
files on folder dist:
[enter image description here](https://i.sstatic.net/6HKOfwEB.png)
I found this solution, but have the same results (wiyh async runs and dont copy the files, without async got the error Did you forget to signal sync completion?)
const fs = require("fs");
gulp.task('default', function (callback) {
try {
fs.copyFile("./img/background.jpg", "./image/background.jpg", callback);
} catch (e) {
// nth
}
});
what am I doing wrong?
My OS is Windows 10 Home, 22H2, OS comp.: 19045.4529
Copy files between folders
amen0103 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.