GitXplorerGitXplorer
q

require-resolve

public
7 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
6a57d65c5f0c275be3dcaf67239cf464dca76b86

update readme

qqiu8310 committed 10 years ago
Unverified
e980b3d78acd8d4c76abe12064867af515a40843

fix x-path miss problem

qqiu8310 committed 10 years ago
Unverified
4c41f366e571b75ab1e6e92b0450f0313ddee696

update travis

qqiu8310 committed 10 years ago
Unverified
03fea9972bec7b5759aa7b4a5ae0c68f947dad2a

init

qqiu8310 committed 10 years ago

README

The README file for this repository.

require-resolve

NPM version Build Status Dependency Status Code Climate Coverage Status

Use the node way to resolve required path to absolute path.

The node way

Install

$ npm install --save require-resolve

Usage

Return null if nothing found, otherwise return an object, include src and pkg, pkg is optional.

var requireResolve = require('../'),
  path = require('path');

// Resolve a absolute file
console.log(requireResolve(__filename));

// Resolve a relative file
console.log(requireResolve('./example/simple.js', path.dirname(path.dirname(__filename))));


// output:
/*
{
  src: '/Users/{your_name}/Workspace/require-resolve/example/simple.js',
  pkg: {
    name: 'require-resolve',
    version: '0.0.1',
    main: 'src/require-resolve.js',
    root: '/Users/{your_name}/Workspace/require-resolve'
  }
}
*/


// Resolve a node module file
console.log(requireResolve('glup', __filename));
console.log(requireResolve('glup/taskTree', __filename));

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using gulp.

License

Copyright (c) 2015 Zhonglei Qiu. Licensed under the MIT license.