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.

README.md 5.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # normalize-path [![NPM version](https://img.shields.io/npm/v/normalize-path.svg?style=flat)](https://www.npmjs.com/package/normalize-path) [![NPM monthly downloads](https://img.shields.io/npm/dm/normalize-path.svg?style=flat)](https://npmjs.org/package/normalize-path) [![NPM total downloads](https://img.shields.io/npm/dt/normalize-path.svg?style=flat)](https://npmjs.org/package/normalize-path) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/normalize-path.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/normalize-path)
  2. > Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes unless disabled.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install --save normalize-path
  7. ```
  8. ## Usage
  9. ```js
  10. var normalize = require('normalize-path');
  11. normalize('\\foo\\bar\\baz\\');
  12. //=> '/foo/bar/baz'
  13. normalize('./foo/bar/baz/');
  14. //=> './foo/bar/baz'
  15. ```
  16. Pass `false` as the last argument to **keep** trailing slashes:
  17. ```js
  18. normalize('./foo/bar/baz/', false);
  19. //=> './foo/bar/baz/'
  20. normalize('foo\\bar\\baz\\', false);
  21. //=> 'foo/bar/baz/'
  22. ```
  23. ## About
  24. ### Related projects
  25. * [contains-path](https://www.npmjs.com/package/contains-path): Return true if a file path contains the given path. | [homepage](https://github.com/jonschlinkert/contains-path "Return true if a file path contains the given path.")
  26. * [ends-with](https://www.npmjs.com/package/ends-with): Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for… [more](https://github.com/jonschlinkert/ends-with) | [homepage](https://github.com/jonschlinkert/ends-with "Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for comparisons.")
  27. * [is-absolute](https://www.npmjs.com/package/is-absolute): Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute "Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute.")
  28. * [is-relative](https://www.npmjs.com/package/is-relative): Returns `true` if the path appears to be relative. | [homepage](https://github.com/jonschlinkert/is-relative "Returns `true` if the path appears to be relative.")
  29. * [parse-filepath](https://www.npmjs.com/package/parse-filepath): Pollyfill for node.js `path.parse`, parses a filepath into an object. | [homepage](https://github.com/jonschlinkert/parse-filepath "Pollyfill for node.js `path.parse`, parses a filepath into an object.")
  30. * [path-ends-with](https://www.npmjs.com/package/path-ends-with): Return `true` if a file path ends with the given string/suffix. | [homepage](https://github.com/jonschlinkert/path-ends-with "Return `true` if a file path ends with the given string/suffix.")
  31. * [path-segments](https://www.npmjs.com/package/path-segments): Get n specific segments of a file path, e.g. first 2, last 3, etc. | [homepage](https://github.com/jonschlinkert/path-segments "Get n specific segments of a file path, e.g. first 2, last 3, etc.")
  32. * [rewrite-ext](https://www.npmjs.com/package/rewrite-ext): Automatically re-write the destination extension of a filepath based on the source extension. e.g… [more](https://github.com/jonschlinkert/rewrite-ext) | [homepage](https://github.com/jonschlinkert/rewrite-ext "Automatically re-write the destination extension of a filepath based on the source extension. e.g `.coffee` => `.js`. This will only rename the ext, no other path parts are modified.")
  33. * [unixify](https://www.npmjs.com/package/unixify): Convert Windows file paths to unix paths. | [homepage](https://github.com/jonschlinkert/unixify "Convert Windows file paths to unix paths.")
  34. ### Contributing
  35. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  36. ### Contributors
  37. | **Commits** | **Contributor** |
  38. | --- | --- |
  39. | 31 | [jonschlinkert](https://github.com/jonschlinkert) |
  40. | 1 | [phated](https://github.com/phated) |
  41. ### Building docs
  42. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  43. To generate the readme, run the following command:
  44. ```sh
  45. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  46. ```
  47. ### Running tests
  48. Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
  49. ```sh
  50. $ npm install && npm test
  51. ```
  52. ### Author
  53. **Jon Schlinkert**
  54. * [github/jonschlinkert](https://github.com/jonschlinkert)
  55. * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  56. ### License
  57. Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
  58. Released under the [MIT License](LICENSE).
  59. ***
  60. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 29, 2017._