K
K
Konstantin_Sh2021-09-06 16:43:15
gulp.js
Konstantin_Sh, 2021-09-06 16:43:15

How to save the information from the pipe into a variable and use this variable in the stream in the future?

I'm using gulp for layout, and I want to make it so that the finished layout can be converted from htmlto phpfor wordpress. I'm stuck on the fact that I need to replace everything and with and . I was able to get the file paths using the module , but the problem is that I can't get everything out of the pipe and save it to a variable. I tried displaying the information at least in the console, but that didn't work either. Here is my code:<link><script>wp__enque_styleswp_enque_scriptsgulp-find

let gulp = require("gulp"),
     es = require("event-stream"),
     fs = require("fs"),
     find = require("gulp-find"),
     rename = require("gulp-rename");

const action = es => es.map((file, cb) => {
    console.log(file.path);
    return cb();
});

gulp.task("wp", () => {

    return src(project.src.html) // открыли файл
        .pipe(find(/([`"'])\S+?\.(css|js)\1/gi)) // нашли все пути
        .pipe(action(es)) // вызвали вывод путей в консоль
        .pipe(rename({ extname: ".php" }))
        .pipe(dest(project.build.php))
})

Information about the completion of the task is displayed in the console, but the information found in the file is not displayed:
613617a149d24068650611.png

What am I doing wrong? How to correctly process information using pipe and output it to the console? And then, save it to a variable for later work?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question