Upsearch
Attempts to resolve a path by walking up from a specified directory.
Installation
$ npm install utils-upsearch
Usage
var upsearch = ;
upsearch( path, [ options,] clbk )
Attempts to resolve a (file or directory) path
by walking up from a specified directory.
;{if errorreturn console;if path === nullreturn console;console;// returns /path/to/.npmrc}
By default, the function
begins searching in the current working directory. To begin searching from a different directory, set the dir
option.
var opts ='dir': '/path/to/a/directory';;
upsearch.sync( path[, options] )
Synchronously attempts to resolve a (file or directory) path
by walking up from a specified directory.
var path = upsearch;// returns /path/to/.npmrc
To begin searching from a particular directory, set the dir
option.
var opts ='dir': '/path/to/a/directory';var path = upsearch;// returns /path/to/.npmrc
If unable to resolve a path
, the method returns null
.
var path = upsearch;// returns null
Examples
var readFile = ;// Sync:var path = upsearch;console;// returns /path/to/utils-upsearchpath = upsearch;console;// returns null// Async:;;{if errorthrow error;console;}
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
License
Copyright
Copyright © 2015-2016. Athan Reines.