A
A
Artyom Innokentiev2016-03-08 00:08:24
Node.js
Artyom Innokentiev, 2016-03-08 00:08:24

How to copy nested files but without parent folders (Gulp.js)?

Let's say the structure is like this:

1
└── 2
    └── 3
        └── copyme.js

We need to copy the copyme.js file to a specific destination folder - how do we do that? At the same time, it is necessary to take into account:
1) There are a lot of copied files, as well as folders containing them (glob must be registered root/**/*.js)
2) destinationONLY files (without parent folders) must be copied to. it should look something like this:
destination/
├── copyme1.js
├── copyme2.js
└── copyme3.js

3) You need to keep the original file name when copying
. My task code does not do this - it copies files with parent folders:
var path = {
    src: 'root/**/*.js',
    dest: 'destination'
};

gulp.task('copy', function(){
    return gulp.src(path.src)
        .pipe(gulp.dest(path.dest))
});

How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Filippov, 2016-03-08
@artinnok

https://www.google.co.th/search?q=gulp+copy+withou...

K
Kirill Nefediev, 2020-06-18
@Traineratwot

var rename = require('gulp-rename');

gulp.src('app/client/**/*.html')
  .pipe(rename({dirname: ''}))
  .pipe(gulp.dest('dist'));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question