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

resolve-dependency-path

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-dependency-path - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

34

index.js

@@ -12,9 +12,9 @@ 'use strict';

*/
module.exports = function({ dependency: dep, filename, directory } = {}) {
if (!dep) throw new Error('dependency path not given');
module.exports = function({ dependency, filename, directory } = {}) {
if (!dependency) throw new Error('dependency path not given');
if (!filename) throw new Error('filename not given');
if (!directory) throw new Error('directory not given');
const filepath = getDependencyPath(dep, filename, directory);
const ext = getDependencyExtension(dep, filename);
const filepath = getDependencyPath(dependency, filename, directory);
const ext = getDependencyExtension(dependency, filename);

@@ -25,11 +25,3 @@ return filepath + ext;

/**
* @param {String} dep
* @return {Boolean}
*/
function isRelative(dep) {
return dep.indexOf('..') === 0 || dep.indexOf('.') === 0;
}
/**
* @param {String} dep
* @param {String} dependency
* @param {String} filename

@@ -39,17 +31,17 @@ * @param {String} directory

*/
function getDependencyPath(dep, filename, directory) {
if (isRelative(dep)) {
return path.resolve(path.dirname(filename), dep);
function getDependencyPath(dependency, filename, directory) {
if (dependency.indexOf('..') === 0 || dependency.indexOf('.') === 0) {
return path.resolve(path.dirname(filename), dependency);
}
return path.resolve(directory, dep);
return path.resolve(directory, dependency);
}
/**
* @param {String} dep
* @param {String} dependency
* @param {String} filename
* @return {String} The determined extension for the dependency (or empty if already supplied)
*/
function getDependencyExtension(dep, filename) {
const depExt = path.extname(dep);
function getDependencyExtension(dependency, filename) {
const depExt = path.extname(dependency);
const fileExt = path.extname(filename);

@@ -63,3 +55,3 @@

// in .js AND doesn't use a custom plugin, add .js back to path
if (fileExt === '.js' && depExt !== '.js' && !dep.includes('!')) {
if (fileExt === '.js' && depExt !== '.js' && !dependency.includes('!')) {
return fileExt;

@@ -66,0 +58,0 @@ }

{
"name": "resolve-dependency-path",
"version": "3.0.0",
"version": "3.0.1",
"description": "Convert a dependency path into a filepath",

@@ -5,0 +5,0 @@ "main": "index.js",

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