File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -966,7 +966,7 @@ lrGeneratorMixin.generateCommonJSModule = function generateCommonJSModule (opt)
966
966
opt = typal . mix . call ( { } , this . options , opt ) ;
967
967
var moduleName = opt . moduleName || "parser" ;
968
968
var out = this . generateModule ( opt )
969
- + "\n\n\nif (typeof require !== 'undefined' && typeof exports !== 'undefined' && new Function('try{return this===global;}catch(e){return false;}')() ) {"
969
+ + "\n\n\nif (typeof require !== 'undefined' && typeof exports !== 'undefined') {"
970
970
+ "\nexports.parser = " + moduleName + ";"
971
971
+ "\nexports.Parser = " + moduleName + ".Parser;"
972
972
+ "\nexports.parse = function () { return " + moduleName + ".parse.apply(" + moduleName + ", arguments); };"
@@ -1280,7 +1280,12 @@ function commonjsMain (args) {
1280
1280
console . log ( 'Usage: ' + args [ 0 ] + ' FILE' ) ;
1281
1281
process . exit ( 1 ) ;
1282
1282
}
1283
- var source = require ( 'fs' ) . readFileSync ( require ( 'path' ) . normalize ( args [ 1 ] ) , "utf8" ) ;
1283
+ var source = null ;
1284
+ var fs = require ( 'fs' ) ;
1285
+ var path = require ( 'path' ) ;
1286
+ if ( typeof fs !== 'undefined' && fs !== null ) {
1287
+ source = fs . readFileSync ( path . normalize ( args [ 1 ] ) , "utf8" ) ;
1288
+ }
1284
1289
return exports . parser . parse ( source ) ;
1285
1290
}
1286
1291
You can’t perform that action at this time.
0 commit comments