I have an object array and i am using gulp 4.
libs:
{
a: {
js: [
{
src: 'path/from/a1.js',
dest: 'path/to/a1.js',,
},
{
src: 'path/from/a2.js',
dest: 'path/to/a2.js',,
},
],
css: [
{
src: 'path/from/a1.css',
dest: 'path/to/b1.css',,
},
],
},
b: {
js: [
{
src: 'path/from/b.js',
dest: 'path/to/b.js',,
},
],
},
}
I need to know all the src and dest values so that I can move files from src to dest.
const moveLibs = (done) => {
Object.entries(libs).forEach(([key, value]) => {
const types = value;
Object.entries(types).forEach(([key, value]) => {
const srcAndDest = value;
Object.entries(srcAndDest).forEach(([key, value]) => {
return gulp
.src(value.src)
.pipe(gulp.dest(value.dest));
});
});
});
done();
};
This method is successful, but I feel that it is not simple enough, please tell me a simpler method, thank you.