Ask Your Question
0

What is the method to retrieve the name of the file that is currently in use in gulp.src()?

asked 2023-03-23 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-04-04 20:00:00 +0000

qstack gravatar image

In order to retrieve the name of the file that is currently in use in gulp.src(), you can use the gulp-debug plugin. This plugin will log the name of each file as it passes through the gulp stream.

Here's an example of how to use the gulp-debug plugin:

const gulp = require('gulp');
const debug = require('gulp-debug');

gulp.task('myTask', function() {
  return gulp.src('src/*.js')
    .pipe(debug({title: 'File: '}))
    .pipe(gulp.dest('dist/'));
});

In this example, the gulp.src() function is used to select all JavaScript files in the "src" directory. Then, the gulp-debug plugin is used to log the name of each file as it passes through the stream. Finally, the files are output to the "dist" directory using the gulp.dest() function.

The output in the console will show the name of each file as it is processed, prefixed with the string "File: ":

[17:22:51] File: app.js
[17:22:51] File: main.js
[17:22:51] File: plugin.js
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-03-23 11:00:00 +0000

Seen: 7 times

Last updated: Apr 04 '22