Socket
Socket
Sign inDemoInstall

unixify

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unixify - npm Package Compare versions

Comparing version 0.2.1 to 1.0.0

11

index.js
/*!
* unixify <https://github.com/jonschlinkert/unixify>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT license.
* Copyright (c) 2014, 2017, Jon Schlinkert.
* Released under the MIT License.
*/

@@ -10,6 +10,7 @@

var normalize = require('normalize-path');
var normalizePath = require('normalize-path');
module.exports = function unixify(fp) {
return normalize(fp).replace(/^\w+:/, '');
module.exports = function unixify(filepath, stripTrailing) {
filepath = normalizePath(filepath, stripTrailing);
return filepath.replace(/^([a-zA-Z]+:|\.\/)/, '');
};
{
"name": "unixify",
"description": "Convert Windows file paths to unix paths.",
"version": "0.2.1",
"version": "1.0.0",
"homepage": "https://github.com/jonschlinkert/unixify",

@@ -12,3 +12,5 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"license": "MIT",
"files": ["index.js"],
"files": [
"index.js"
],
"main": "index.js",

@@ -22,6 +24,7 @@ "engines": {

"dependencies": {
"normalize-path": "^2.0.0"
"normalize-path": "^2.1.1"
},
"devDependencies": {
"mocha": "*"
"gulp-format-md": "^0.1.12",
"mocha": "^3.2.0"
},

@@ -43,2 +46,3 @@ "keywords": [

"unix",
"unixify",
"urix",

@@ -54,11 +58,18 @@ "windows"

"is-absolute",
"is-relative",
"normalize-path",
"parse-filepath",
"path-ends-with",
"path-segments",
"rewrite-ext"
"path-ends-with"
]
},
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
}
}
}

@@ -1,11 +0,19 @@

# unixify [![NPM version](https://badge.fury.io/js/unixify.svg)](http://badge.fury.io/js/unixify)
# unixify [![NPM version](https://img.shields.io/npm/v/unixify.svg?style=flat)](https://www.npmjs.com/package/unixify) [![NPM monthly downloads](https://img.shields.io/npm/dm/unixify.svg?style=flat)](https://npmjs.org/package/unixify) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/unixify.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/unixify)
> Convert Windows file paths to unix paths.
Install with [npm](https://www.npmjs.com/)
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm i unixify --save
$ npm install --save unixify
```
Install with [yarn](https://yarnpkg.com):
```sh
$ yarn add unixify
```
## Usage

@@ -15,62 +23,92 @@

var unixify = require('unixify');
unixify(filepath[, stripTrailingSlash]);
```
unixify('one\\two\\three');
//=> 'one/two/three'
**Strips leading drive letters and dot-slash (`./`)**
unixify('one\\two\\//three');
//=> 'one/two/three'
```js
unixify('.\\one\\two\\three'); //=> 'one/two/three'
unixify('./one/two/three'); //=> 'one/two/three'
unixify('C:\\one\\two\\three'); //=> '/one/two/three'
unixify('\\one\\two\\three'); //=> '/one/two/three'
```
unixify('C:\\one\\two\\three');
//=> '/one/two/three'
**Normalizes path separators to forward slashes**
unixify('C:\\//one\\//two\\//three');
//=> '/one/two/three'
```js
unixify('one\\two\\three'); //=> 'one/two/three'
unixify('\\one\\two\\three'); //=> '/one/two/three'
unixify('C:\\one\\two\\three'); //=> '/one/two/three'
```
unixify('C:\\//one\\two\\three');
//=> '/one/two/three'
**Combines multiple consecutive slashes**
unixify('C:\\//one\\two\\//three');
//=> '/one/two/three'
```js
unixify('one//two//////three'), //=> 'one/two/three'
unixify('\\one\\two\\//three'); //=> '/one/two/three'
unixify('C:\\//one\\two\\//three'); //=> '/one/two/three'
```
## Related
**Strips trailing slashes by default**
Other useful libraries for working with paths in node.js:
```js
unixify('one//two//////three//'), //=> 'one/two/three'
unixify('C:\\one\\two\\three\\'); //=> '/one/two/three'
```
* [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)
* [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://www.npmjs.com/package/ends-with) | [homepage](https://github.com/jonschlinkert/ends-with)
* [is-absolute](https://www.npmjs.com/package/is-absolute): Return true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute)
* [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)
* [normalize-path](https://www.npmjs.com/package/normalize-path): Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a… [more](https://www.npmjs.com/package/normalize-path) | [homepage](https://github.com/jonschlinkert/normalize-path)
* [parse-filepath](https://www.npmjs.com/package/parse-filepath): Parse a filepath into an object. Falls back on the native node.js `path.parse` method if… [more](https://www.npmjs.com/package/parse-filepath) | [homepage](https://github.com/jonschlinkert/parse-filepath)
* [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)
* [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)
* [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://www.npmjs.com/package/rewrite-ext) | [homepage](https://github.com/jonschlinkert/rewrite-ext)
**Keep trailing slashes**
## Running tests
By passing `false` as the second argument
Install dev dependencies:
```js
unixify('one//two//////three//'), //=> 'one/two/three/'
unixify('C:\\one\\two\\three\\'); //=> '/one/two/three/'
```
## About
### Related projects
* [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.")
* [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.")
* [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.")
* [normalize-path](https://www.npmjs.com/package/normalize-path): Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a… [more](https://github.com/jonschlinkert/normalize-path) | [homepage](https://github.com/jonschlinkert/normalize-path "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.")
* [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.")
### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
### Building docs
_(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.)_
To generate the readme, run the following command:
```sh
$ npm i -d && npm test
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
## Contributing
### Running tests
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/unixify/issues/new).
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:
## Author
```sh
$ npm install && npm test
```
### Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
## License
### License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 04, 2015._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 14, 2017._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc