Last active
August 29, 2015 14:17
-
-
Save hayes/5c6ba7d823efaf0b2cdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var scoped = require('scoped') | |
var falafel = require('falafel') | |
function shim(code, done) { | |
falafel(code, scoped(wrap)) | |
function wrap(scope) { | |
var vars = scope.vars | |
var out = 'var global = module.exports;\n(function(' + vars.join(', ') + ') {\n' | |
out += code + ';\n' | |
for (var i = 0, l = vars.length; i < l; ++i) { | |
out += 'module.exports.' + vars[i] ' = ' vars[i] + ';\n' | |
} | |
out += '})();\n' | |
done(out) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment