Skip to content

Commit a27d0a2

Browse files
committedApr 13, 2015
Update deps and move to streams2
1 parent 664c862 commit a27d0a2

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed
 

‎lib/script-injector.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var trumpet = require('trumpet')
2-
, duplexer = require('duplexer')
3-
, through = require('through');
2+
, duplexer = require('duplexer2')
3+
, through = require('through2');
44

55
function scriptInjector (script) {
66
var tr1 = trumpet()
@@ -15,23 +15,27 @@ function scriptInjector (script) {
1515

1616
firstScriptTag // Inject the new script before the first existing <script>
1717
.pipe(through(
18-
function (data) {
18+
function (data, enc, cb) {
1919
if (needToAddScript) {
20-
this.queue(script);
20+
this.push(script);
2121
needToAddScript = false;
2222
}
23-
this.queue(data);
23+
this.push(data);
24+
cb();
2425
}))
2526
.pipe(firstScriptTag);
2627

2728
bodyTag // If there were no <script>'s, insert the script right before </body>
2829
.pipe(through(
29-
null,
30+
function (data, enc, cb) {
31+
this.push(data);
32+
cb();
33+
},
3034
function () {
3135
if (needToAddScript) {
32-
this.queue(script);
36+
this.push(script);
3337
}
34-
this.queue(null);
38+
this.push(null);
3539
}))
3640
.pipe(bodyTag);
3741

‎package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "script-injector",
3-
"version": "0.1.7",
3+
"version": "1.0.0",
44
"description": "Inject inline javascript into an HTML stream.",
55
"main": "index.js",
66
"scripts": {
@@ -22,12 +22,12 @@
2222
"author": "David Manning",
2323
"license": "MIT",
2424
"dependencies": {
25-
"trumpet": "~1.6.3",
26-
"through": "~2.3.4",
27-
"duplexer": "~0.1.1"
25+
"duplexer2": "0.0.2",
26+
"through2": "^0.6.5",
27+
"trumpet": "^1.7.1"
2828
},
2929
"devDependencies": {
30-
"tape": "~1.1.0",
31-
"concat-stream": "~1.0.1"
30+
"concat-stream": "^1.4.7",
31+
"tape": "^3.5.0"
3232
}
3333
}

‎test/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ test('inject code before the first script tag in the body', testRunner.bind(null
2222

2323
function someCode () {
2424
console.log("I'm some code to be inserted inline");
25-
}
25+
}

0 commit comments

Comments
 (0)