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 0.1.3 to 0.1.4

bower.json

31

index.js
/**
* Relative <https://github.com/jonschlinkert/relative>
* relative <https://github.com/jonschlinkert/relative>
* Copyright (c) 2014 Jon Schlinkert, contributors.

@@ -7,9 +7,21 @@ * Licensed under the MIT license.

'use strict';
const fs = require('fs');
const path = require('path');
var file = require('fs-utils');
var path = require('path');
// True if the filepath is a directory.
function isDir() {
var filepath = path.join.apply(path, arguments);
if (!fs.existsSync(filepath)) {
return false;
}
return fs.statSync(filepath).isDirectory();
}
// Unixify all slashes
function normalizeSlash(str) {
return str.replace(/\\/g, '/');
}
/**

@@ -28,5 +40,5 @@ * Return the relative path from

from = !file.isDir(from) ? path.dirname(from) : from;
from = !isDir(from) ? path.dirname(from) : from;
var rel = path.relative(path.resolve(from), path.resolve(to));
return file.normalizeSlash(rel);
return normalizeSlash(rel);
};

@@ -47,7 +59,10 @@

basepath = path.resolve(basepath);
if (filepath.indexOf(basepath) === 0) {
filepath = filepath.replace(basepath, '');
}
filepath = file.normalizeSlash(filepath);
return filepath.replace(/^\//, '')
filepath = normalizeSlash(filepath);
// Remove leading slash.
return filepath.replace(/^\//, '');
};

@@ -54,0 +69,0 @@

{
"name": "relative",
"version": "0.1.3",
"version": "0.1.4",
"description": "Easily calculate the relative path from file A to file B in Node.js project. Will calculate correctly from a file to a directory, file to file, directory to file, and directory to directory.",

@@ -25,5 +25,2 @@ "repository": {

},
"dependencies": {
"fs-utils": "~0.3.0"
},
"devDependencies": {

@@ -30,0 +27,0 @@ "chai": "~1.9.0",

@@ -13,3 +13,3 @@ /**

var relative = require('../');
var relative = require('./');

@@ -16,0 +16,0 @@ describe('relative', function() {

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