Comparing version 0.2.1 to 0.3.0
@@ -8,3 +8,3 @@ 'use strict'; | ||
tokenFrom = tokenFrom || 'require'; | ||
var ast = esprima.parse(code); | ||
var ast = esprima.parse('!function(){'+code+'}'); | ||
estraverse.traverse(ast,{ | ||
@@ -20,4 +20,4 @@ leave:function(node, parent) { | ||
}); | ||
return escodegen.generate(ast); | ||
return escodegen.generate(ast.body[0].expression.argument.body.body[0]); | ||
} | ||
module.exports = rename; |
{ | ||
"name": "derequire", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "remove requires", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,2 +12,6 @@ var should = require('chai').should(); | ||
}); | ||
it('should handle top level return statments', function(){ | ||
var exampleText = 'return require("require");'; | ||
derequire(exampleText).should.equal("return __derequire__('require');"); | ||
}); | ||
}); |
3384
35