Skip to content

Commit

Permalink
[Tests] patch through so it works pre-node-0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 5, 2023
1 parent 7e7c3d0 commit 246a439
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/_patch-through.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

var Stream = require('stream');

if (Stream !== Stream.Stream) {
var orig = require.extensions['.js'];

require.extensions['.js'] = function (module, file) {
if (file === require.resolve('through')) {
var oldCompile = module._compile;
module._compile = function (code, file) {
module._compile = oldCompile;
module._compile(code.replace(/^var Stream = require\('stream'\)\n/, 'var Stream = require(\'stream\').Stream;\n'), file);
};
}
orig(module, file);
};
require('through');
}

0 comments on commit 246a439

Please sign in to comment.