Skip to content

Instantly share code, notes, and snippets.

@buehler
Last active August 29, 2015 14:26
Show Gist options
  • Save buehler/166bdab800e09eb5339a to your computer and use it in GitHub Desktop.
Save buehler/166bdab800e09eb5339a to your computer and use it in GitHub Desktop.
Wrapper for require to prevent fails in absolute pathes for windows. (Because windows does have problems with absolute paths. -> with this global function, all require actions are using "path.join")
global.__require = function () {
if (arguments.length <= 0) throw new Error('No arguments provided.');
var join = '';
for (var arg in arguments) {
if (arguments.hasOwnProperty(arg)) {
join = path.join(join, arguments[arg]);
}
}
return require(join);
};
//usage:
var file = __require('myNodeFolder', 'subFolder', 'file');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment