ericdouglas / path-to

A simple abstraction to identify the path and request your files and folders in a Node.js project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

path-to

Build Status Coverage Status

NPM

Description

A simple abstraction to identify the path and request your files and folders in a Node.js project.

Installation

npm install path-to --save

Usage

Without path-to module:

var dep1 = require( '../../../../file' );
var dep2 = require( '../../../../../../folder' );
var dep3 = require( '../../../folder' );
var dep4 = require( '../../../another-folder' );

With path-to module:

var path = require( 'path-to' );

var dep1 = require( path( 4, 'file' ));
var dep2 = require( path( 6, 'folder' ));
var dep3 = require( path( 3, 'folder' ));
var dep4 = require( path( 3, 'another-folder' ));

If you want to use just the ../../../ abstraction, you could use the path-to in that manner:

var path = require( 'path-to' )( 4 );

var dep1 = require( path + 'file' );
var dep2 = require( path + 'folder' );
var dep4 = require( path + 'another-folder' );

Real Example

You could look at this folder to see a working example.

In app.js file, we loaded the path-to module and used it in two different forms.

Tests

npm test

Contributing

  • Take care to maintain the existing coding style.
  • Add unit tests for any new or changed functionality.
  • Lint and test your code.

License

The MIT License (MIT)

Copyright (c) 2014-2015 Eric Douglas

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A simple abstraction to identify the path and request your files and folders in a Node.js project


Languages

Language:JavaScript 100.0%