File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ SCOPE_SENTINEL
Original file line number Diff line number Diff line change
1
+ var fs = require ( 'fs' ) ;
2
+ var path = require ( 'path' ) ;
3
+ var dynamicallyCreatedFilename = path . join ( '/files/' , 'somefile' ) ;
4
+ fs . readFileSync ( __dirname + dynamicallyCreatedFilename + __dirname , 'utf8' ) ;
5
+ function x ( fs ) {
6
+ fs . readFileSync ( 'doesNotExist' )
7
+ }
8
+ fs . readFileSync ( __dirname + '/scope-sentinel' )
9
+ require ( 'fs' ) . readFileSync ( __dirname + '/scope-sentinel' )
Original file line number Diff line number Diff line change
1
+ var test = require ( 'tap' ) . test ;
2
+ var browserify = require ( 'browserify' ) ;
3
+ var path = require ( 'path' ) ;
4
+
5
+ test ( 'scope' , function ( t ) {
6
+ t . plan ( 4 ) ;
7
+
8
+ var b = browserify ( { node : true } ) ;
9
+ b . add ( __dirname + '/files/scope' ) ;
10
+ b . transform ( path . dirname ( __dirname ) ) ;
11
+
12
+ b . bundle ( function ( err , src ) {
13
+ if ( err ) t . fail ( err ) ;
14
+ t . pass ( 'build success' ) ;
15
+ src = src . toString ( ) ;
16
+ console . log ( src )
17
+ t . ok ( src . indexOf ( "require('fs')" ) !== - 1 , 'kept the require call' ) ;
18
+ var sentinel = new Buffer ( 'SCOPE_SENTINEL\n' , 'utf8' ) . toString ( 'base64' )
19
+ var i = src . indexOf ( sentinel ) ;
20
+ t . ok ( i !== - 1 , 'read the file' ) ;
21
+ i = src . indexOf ( sentinel , i + 10 ) ;
22
+ t . ok ( i !== - 1 , 'did the require("fs").readFileSync' ) ;
23
+ } ) ;
24
+
25
+ } ) ;
You can’t perform that action at this time.
0 commit comments