marijnh/tern — pull request #275 by sqs (2014-01-15 07:12:47+00:00)
Title: Standardize on using relative paths for node files (and the origins of definitions therein)

This PR fixes the node plugin's filename resolution to always use relative paths. The previous behavior was to preserve the path as-is for files loaded via `server.addFile` and to absolutize paths for modules loaded via `require`.

This improves 2 things:

1) Testing improvement: Node file origins (and the origins of definitions therein) are now standardized to be relative paths, which makes it possible to add test cases for the origin of a type (like the included one in test/cases/node_origin_paths.js).

2) Bug fix: If a file is loaded via `server.addFile` *and* via `require` (for example, `bin/condense --plugin node a.js b.js` where `a.js` contains `require('./b')`), then tern now resolves those 2 ways of referring to the same file. Previously this would have caused tern to treat the same file as 2 different files and create a whole new scope, etc., for both.

The included test case passes. Without the patch to `plugin/node.js`, the failure message is:

```
$ bin/test
node_origin_paths.js, line 3: Found origin
/home/sqs/src/github.com/sqs/tern/test/cases/node_exports.js
instead of expected origin
node_exports.js
Ran 370 tests from 60 files.
1 failures!
```