Created
August 26, 2016 17:32
-
-
Save Ravenstine/1c637d5f26513882a4482e128209d435 to your computer and use it in GitHub Desktop.
A simple function to include non-module JavaScript code in a Node.js project.
This file contains hidden or 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 self = this; | |
var include = function(){ | |
var len = Object.keys(arguments).length; | |
var code = ''; | |
var i = 0; | |
while(i < len){ | |
var file = arguments[i]; | |
code += (fs.readFileSync(embeditorRoot + "/" + file + '.js', "utf8") + "\n"); | |
i++; | |
} | |
(function(){ | |
eval(code); | |
}).call(self); | |
} | |
// EXAMPLE: | |
// include('jquery', 'app', 'libs') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment