You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.3 KiB

4 years ago
  1. # resolve-dir [![NPM version](https://img.shields.io/npm/v/resolve-dir.svg?style=flat)](https://www.npmjs.com/package/resolve-dir) [![NPM downloads](https://img.shields.io/npm/dm/resolve-dir.svg?style=flat)](https://npmjs.org/package/resolve-dir) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/resolve-dir.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/resolve-dir)
  2. > Resolve a directory that is either local, global or in the user's home directory.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install --save resolve-dir
  7. ```
  8. ## Usage
  9. ```js
  10. var resolve = require('resolve-dir');
  11. ```
  12. Returns a local directory path unchanged
  13. ```js
  14. resolve('a')
  15. //=> 'a'
  16. ```
  17. Resolves the path to user home
  18. ```js
  19. resolve('~')
  20. //=> '/Users/jonschlinkert'
  21. resolve('~/foo')
  22. //=> '/Users/jonschlinkert/foo'
  23. ```
  24. Resolves the path to global npm modules
  25. ```js
  26. resolve('@')
  27. //=> '/usr/local/lib/node_modules'
  28. resolve('@/foo')
  29. //=> '/usr/local/lib/node_modules/foo'
  30. ```
  31. ## About
  32. ### Related projects
  33. * [expand-tilde](https://www.npmjs.com/package/expand-tilde): Bash-like tilde expansion for node.js. Expands a leading tilde in a file path to the… [more](https://github.com/jonschlinkert/expand-tilde) | [homepage](https://github.com/jonschlinkert/expand-tilde "Bash-like tilde expansion for node.js. Expands a leading tilde in a file path to the user home directory, or `~+` to the cwd.")
  34. * [findup-sync](https://www.npmjs.com/package/findup-sync): Find the first file matching a given pattern in the current directory or the nearest… [more](https://github.com/cowboy/node-findup-sync) | [homepage](https://github.com/cowboy/node-findup-sync "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.")
  35. * [resolve-modules](https://www.npmjs.com/package/resolve-modules): Resolves local and global npm modules that match specified patterns, and returns a configuration object… [more](https://github.com/jonschlinkert/resolve-modules) | [homepage](https://github.com/jonschlinkert/resolve-modules "Resolves local and global npm modules that match specified patterns, and returns a configuration object for each resolved module.")
  36. ### Contributing
  37. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  38. ### Building docs
  39. _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
  40. To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
  41. ```sh
  42. $ npm install -g verb verb-generate-readme && verb
  43. ```
  44. ### Running tests
  45. Install dev dependencies:
  46. ```sh
  47. $ npm install -d && npm test
  48. ```
  49. ### Author
  50. **Jon Schlinkert**
  51. * [github/jonschlinkert](https://github.com/jonschlinkert)
  52. * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  53. ### License
  54. Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
  55. Released under the [MIT license](https://github.com/jonschlinkert/resolve-dir/blob/master/LICENSE).
  56. ***
  57. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 18, 2016._