timrwood/includer — pull request #12 by timrwood (2014-05-10 18:31:24+00:00)
Title: Paths config (round 2)

This is a followup PR to #11. /cc @isochronous

This adds the ability to start an include path with an `@base` segment.

```js
include('@base/scripts/app.js');
```

Now, rather than the include statement being relative to the current file, it will be relative to the current working directory.

```js
// cwd: /Users/timrwood/

// file: /Users/timrwood/scripts/a.js
include('./c.js'); //Users/timrwood/scripts/c.js

// file: /Users/timrwood/scripts/b.js
include('@base/c.js'); //Users/timrwood/c.js
```

Additionally, users can define their own mappings. These paths are all resolved relative to the current working directory.

```js
includer(file, {
paths : {
libs : 'project/source/libs',
app : 'project/source/js'
}
}, done);
```

These are used the same way as `@base`.

```js
// cwd: /Users/timrwood/my-project

include('@libs/jquery/jquery'); //Users/timrwood/my-project/project/source/libs/jquery/jquery.js
include('@libs/handlebars/handlebars'); //Users/timrwood/my-project/project/source/libs/handlebars/handlebars.js
include('@libs/ember/ember'); //Users/timrwood/my-project/project/source/libs/ember/ember.js
var App = Ember.Application.create();
include('@app/router'); //Users/timrwood/my-project/project/source/js/router.js
include('@app/routes/*'); //Users/timrwood/my-project/project/source/js/routers/*.js
```

If needed, it is also possible to override `@base`.

```js
includer(file, {
paths : {
base : '../new/path/to/base/'
}
}, done);
```