File tree 2 files changed +29
-2
lines changed
2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ var fs = require('fs');
94
94
95
95
var files = [ ' ./files/x.js' , ' ./files/y.js' ];
96
96
var b = browserify (files);
97
- b .plugin (' factor-bundle' , { o : [ ' bundle/x.js' , ' bundle/y.js' ] });
97
+ b .plugin (' factor-bundle' , { outputs : [ ' bundle/x.js' , ' bundle/y.js' ] });
98
98
b .bundle ().pipe (fs .createWriteStream (' bundle/common.js' ));
99
99
```
100
100
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ var files = [
15
15
var tmpdir = tmp ( ) + '/factor-bundle-' + Math . random ( ) ;
16
16
mkdirp . sync ( tmpdir ) ;
17
17
18
- test ( 'outputs api ' , function ( t ) {
18
+ test ( 'file outputs ' , function ( t ) {
19
19
t . plan ( 2 ) ;
20
20
var b = browserify ( files ) ;
21
21
b . plugin ( factor , {
@@ -41,3 +41,30 @@ test('outputs api', function (t) {
41
41
} } } ) ;
42
42
} ) ;
43
43
} ) ;
44
+
45
+ test ( 'stream outputs' , function ( t ) {
46
+ t . plan ( 2 ) ;
47
+ var sources = { } , pending = 3 ;
48
+ function write ( key ) {
49
+ return concat ( function ( body ) {
50
+ sources [ key ] = body . toString ( 'utf8' ) ;
51
+ if ( -- pending === 0 ) done ( ) ;
52
+ } ) ;
53
+ }
54
+
55
+ var b = browserify ( files ) ;
56
+ b . plugin ( factor , { outputs : [ write ( 'x' ) , write ( 'y' ) ] } ) ;
57
+ b . bundle ( ) . pipe ( write ( 'common' ) ) ;
58
+
59
+ function done ( ) {
60
+ var common = sources . common , x = sources . x , y = sources . y ;
61
+
62
+ vm . runInNewContext ( common + x , { console : { log : function ( msg ) {
63
+ t . equal ( msg , 55500 ) ;
64
+ } } } ) ;
65
+
66
+ vm . runInNewContext ( common + y , { console : { log : function ( msg ) {
67
+ t . equal ( msg , 333 ) ;
68
+ } } } ) ;
69
+ }
70
+ } ) ;
You can’t perform that action at this time.
0 commit comments