Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dedefine.js « scripts « mocha-3.1.0 « lib « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c647c0e083ef6297717e666bf6e58ab30897989c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';

/**
 * This is a transform stream we're using to strip AMD calls from
 * dependencies in our Browserify bundle.
 */

var through = require('through2');
var defineRx = /typeof define === ['"]function['"] && define\.amd/g;

function createStream() {
  return through.obj(function(chunk, enc, next) {
    this.push(String(chunk)
      .replace(defineRx, 'false'));
    next();
  });
}

module.exports = function(b) {
  function wrap() {
    b.pipeline.get('wrap').push(createStream());
  }

  b.on('reset', wrap);
  wrap();
};