1.0.0 • Published 9 years ago

node-global-paths v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

Global Paths

NPM version Build Status Coverage Status Dependencies

Returns Node.js global paths.

Installation

$ npm install node-global-paths

Usage

var paths = require( 'node-global-paths' );

paths

Returns a list of Node global paths.

console.log( paths );
/*
	e.g.,
		[
			'/Users/<user>/.node_modules',
			'/Users/<user>/.node_libraries',
			'/usr/local/<dir>/node/0.12.7/lib/node'
		]
*/

Examples

var cwd = require( 'utils-cwd' )(),
	paths = require( 'node-global-paths' );

var len = paths.length,
	str,
	i;

for ( i = 0; i < len; i++ ) {
	str = cwd.substring( 0, paths[ i ].length );
	if ( str === paths[ i ] ) {
		console.log( 'Process running from a global Node path: %s.', paths[ i ] );
		return;
	}
}
console.log( 'Process is not running from a global Node path.' );

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

MIT license.

Copyright

Copyright © 2015. Athan Reines.