Updated to use require.resolve and readable code.

Using require.resolve means it will work with relative file uris to the actual file rather then to cwd.

Also I made the code readable and actually a node module.