buddy

node MVC discord bot
Log | Files | Refs | README

node_path.js (1252B)


      1 var path = require('path');
      2 var test = require('tape');
      3 var resolve = require('../');
      4 
      5 test('$NODE_PATH', function (t) {
      6     t.plan(4);
      7     
      8     resolve('aaa', {
      9         paths: [
     10             __dirname + '/node_path/x',
     11             __dirname + '/node_path/y'
     12         ],
     13         basedir: __dirname,
     14     }, function (err, res) {
     15         t.equal(res, __dirname + '/node_path/x/aaa/index.js');
     16     });
     17     
     18     resolve('bbb', {
     19         paths: [
     20             __dirname + '/node_path/x',
     21             __dirname + '/node_path/y'
     22         ],
     23         basedir: __dirname,
     24     }, function (err, res) {
     25         t.equal(res, __dirname + '/node_path/y/bbb/index.js');
     26     });
     27     
     28     resolve('ccc', {
     29         paths: [
     30             __dirname + '/node_path/x',
     31             __dirname + '/node_path/y'
     32         ],
     33         basedir: __dirname,
     34     }, function (err, res) {
     35         t.equal(res, __dirname + '/node_path/x/ccc/index.js');
     36     });
     37 
     38     // ensure that relative paths still resolve against the
     39     // regular `node_modules` correctly
     40     resolve('tap', {
     41         paths: [
     42             'node_path',
     43         ],
     44         basedir: 'node_path/x',
     45     }, function (err, res) {
     46         t.equal(res, path.resolve(__dirname, '..', 'node_modules/tap/lib/main.js'));
     47     });
     48 });