D
D
Dania Bagaeff2018-04-21 14:00:48
JavaScript
Dania Bagaeff, 2018-04-21 14:00:48

Passing an array to Gulp?

Hello.
Got a question, got a code

const
    gulp = require('gulp'),
    $ = require('gulp-load-plugins')({
        pattern: '*'
    }),
    dir = require('./.conf/.dirrc.json'),
    pl = [
        $.pug({
            pretty: '\t'
        }),
        $.rename({
            extname: '.php'
        })
    ]
;

It's not running, it throws an error
Error: write after end
at writeAfterEnd (D:\OSPanel\domains\jub\node_modules\readable-stream\lib\_stream_writable.js:288:12)
at DestroyableTransform.Writable.write (D:\OSPanel\domains\jub\node_modules \readable-stream\lib\_stream_writable.js:332:20)
at DestroyableTransform.ondata (D:\OSPanel\domains\jub\node_modules\readable-stream\lib\_stream_readable.js:619:20)
at DestroyableTransform.emit ( events.js:159:13)
at addChunk (D:\OSPanel\domains\jub\node_modules\readable-stream\lib\_stream_readable.js:291:12)
at readableAddChunk (D:\OSPanel\domains\jub\node_modules\ readable-stream\lib\_stream_readable.js:278:11)
at DestroyableTransform.Readable.push (D:\OSPanel\domains\jub\node_modules\readable-stream\lib\_stream_readable.js:245:10)
at DestroyableTransform.Transform.push (D:\OSPanel\domains\jub\node_modules\ readable-stream\lib\_stream_transform.js:148:32)
at DestroyableTransform.notify [as _transform] (D:\OSPanel\domains\jub\node_modules\gulp-notify\lib\notify.js:41:14)
at DestroyableTransform .Transform._read (D:\OSPanel\domains\jub\node_modules\readable-stream\lib\_stream_transform.js:184:10)

If the pl array is moved inside the task, then everything happens fine. The dev:watch:pug task calls dev:pug and rebuilds everything, if the array is in the global scope, be it let or const , it doesn't matter, using the pump plugin does not solve the problem.
gulp-pipe code:
module.exports = function pipe(stream, tubes) {
  tubes = tubes || stream.slice(1);
  return tubes.reduce(function(stream, tube) { return stream.pipe(tube); }, Array.isArray(stream) ? stream[0] : stream);
};

As I understand it, something happens when we pass an array from a common code to a function, I would like to understand

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