I’m not 100% certain what you mean by
copy and rename … in place
But, based on your current code, if you simply wish to:
- Watch all
.jsfiles in the parent directory and - Copy them to the
cwd(current working directory) and - Name all copies, regardless of source file, the same thing
Then you could use gulp-rename to do just that:
var gulp = require('gulp');
var rename = require('gulp-rename');
gulp.task('default', function() {
return gulp.watch('../**/**.js', function(obj) {
gulp.src(obj.path)
.pipe(rename('newFileName.js'))
.pipe(gulp.dest('.'));
});
});
In this case, the output filename is newFileName.js
In order to use the module, you’ll need to install the gulp-rename package with npm (ie: npm install gulp-rename).
More examples are available on the package details page on npm @ https://www.npmjs.com/package/gulp-rename#usage