Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

relative

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

relative - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

5

index.js

@@ -40,3 +40,4 @@ 'use strict';

return path.relative(a, b);
var relativePath = path.relative(a, b);
return relativePath.charAt(0) !== '.' ? './' + relativePath : relativePath;
}

@@ -83,2 +84,2 @@

return str.replace(/[\\\/]+/g, '/');
}
}

2

package.json
{
"name": "relative",
"version": "1.1.0",
"version": "1.2.0",
"description": "Get the relative filepath from path A to path B. Calculates from file-to-directory, file-to-file, directory-to-file, and directory-to-directory.",

@@ -5,0 +5,0 @@ "author": {

@@ -47,3 +47,3 @@ # relative [![NPM version](https://badge.fury.io/js/relative.svg)](http://badge.fury.io/js/relative)

### [.toBase](index.js#L59)
### [.toBase](index.js#L60)

@@ -77,2 +77,2 @@ Get the path relative to the given base path.

_This file was generated by [verb](https://github.com/assemble/verb) on December 20, 2014._
_This file was generated by [verb](https://github.com/assemble/verb) on December 25, 2014._

@@ -22,2 +22,3 @@ /**

normalize(relative('test/fixtures/foo.txt', 'docs/new/file.txt')).should.equal('../../docs/new/file.txt');
normalize(relative('test/fixtures/foo.txt', 'test/fixtures/bar.txt')).should.equal('./bar.txt');
});

@@ -27,2 +28,3 @@

normalize(relative('test\\fixtures\\foo.txt', 'docs')).should.equal('../../docs');
normalize(relative('test\\fixtures\\foo.txt', 'test/fixtures')).should.equal('./');
});

@@ -32,2 +34,3 @@

normalize(relative('test/fixtures', 'docs')).should.equal('../../docs');
normalize(relative('test/foo', 'test/bar')).should.equal('../bar');
});

@@ -37,2 +40,3 @@

normalize(relative('test/fixtures', 'docs/foo.txt')).should.equal('../../docs/foo.txt');
normalize(relative('test/fixtures', 'test/foo.txt')).should.equal('../foo.txt');
});

@@ -45,3 +49,3 @@

it('should resolve the relative path from process.cwd()', function() {
normalize(relative(process.cwd(), 'test/fixtures/foo.txt')).should.equal('test/fixtures/foo.txt');
normalize(relative(process.cwd(), 'test/fixtures/foo.txt')).should.equal('./test/fixtures/foo.txt');
});

@@ -53,3 +57,3 @@ });

it('should resolve the relative path from a file to a file', function() {
var actual = relative('test/fixtures/foo.txt', 'docs/new/file.txt', true)
var actual = relative('test/fixtures/foo.txt', 'docs/new/file.txt')
normalize(actual).should.equal('../../docs/new/file.txt');

@@ -59,3 +63,3 @@ });

it('should resolve the relative path from a file to a directory', function() {
var actual = relative('test/fixtures/foo.txt', 'docs', true)
var actual = relative('test/fixtures/foo.txt', 'docs')
normalize(actual).should.equal('../../docs');

@@ -65,3 +69,3 @@ });

it('should resolve the relative path from a directory to a directory', function() {
var actual = relative('test/fixtures', 'docs', true)
var actual = relative('test/fixtures', 'docs')
normalize(actual).should.equal('../../docs');

@@ -71,3 +75,3 @@ });

it('should resolve the relative path from a directory to a file', function() {
var actual = relative('test/fixtures', 'docs/foo.txt', true)
var actual = relative('test/fixtures', 'docs/foo.txt')
normalize(actual).should.equal('../../docs/foo.txt');

@@ -77,3 +81,3 @@ });

it('should resolve the relative path to process.cwd()', function() {
var actual = relative('test/fixtures/foo.txt', process.cwd(), true)
var actual = relative('test/fixtures/foo.txt', process.cwd())
normalize(actual).should.equal('../..');

@@ -83,4 +87,5 @@ });

it('should resolve the relative path from process.cwd()', function() {
var actual = relative(process.cwd(), 'test/fixtures/foo.txt', true)
normalize(actual).should.equal('test/fixtures/foo.txt');
var actual = relative(process.cwd(), 'test/fixtures/foo.txt')
console.log(actual)
normalize(actual).should.equal('./test/fixtures/foo.txt');
});

@@ -87,0 +92,0 @@ });

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