1 | var structr = require("structr"),
|
2 | resolve = require("resolve");
|
3 |
|
4 | module.exports = structr({
|
5 |
|
6 | |
7 |
|
8 |
|
9 | "__construct": function(loader) {
|
10 | this._loader = loader;
|
11 | this._paths = [process.cwd()];
|
12 | },
|
13 |
|
14 | |
15 |
|
16 |
|
17 | "resolve": function(path) {
|
18 |
|
19 |
|
20 | try {
|
21 | return resolve.sync(path, {
|
22 | paths: this._paths
|
23 | });
|
24 | } catch(e) {
|
25 | return require.resolve(path);
|
26 | }
|
27 | },
|
28 |
|
29 | |
30 |
|
31 |
|
32 | "paths": function() {
|
33 | if(arguments.length) {
|
34 | this._paths.push.apply(this._paths, arguments);
|
35 | } else {
|
36 | return this._paths;
|
37 | }
|
38 | return this._loader;
|
39 | }
|
40 | }); |
\ | No newline at end of file |