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

module-lookup-amd

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-lookup-amd - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1

61

index.js

@@ -7,4 +7,4 @@ 'use strict';

const debug = require('debug')('lookup');
const find = require('find');
const requirejs = require('requirejs');
const glob = require('glob');

@@ -53,28 +53,32 @@ /**

let normalizedModuleId = stripLoader(depPath);
let resolutionDirectory;
if (configPath) {
resolutionDirectory = configPath;
debug('module resolution directory (based on configPath): ' + resolutionDirectory);
if (normalizedModuleId[0] === '.' || (!configPath && !options.directory)) {
resolutionDirectory = path.dirname(options.filename);
debug('module resolution directory (relative): ' + resolutionDirectory);
} else {
if (configPath) {
resolutionDirectory = configPath;
debug('module resolution directory (based on configPath): ' + resolutionDirectory);
} else if (options.directory) {
resolutionDirectory = options.directory;
debug('module resolution directory (based on directory): ' + resolutionDirectory);
}
} else if (options.directory && depPath[0] !== '.') {
resolutionDirectory = options.directory;
debug('module resolution directory (based on directory): ' + resolutionDirectory);
if (config.baseUrl[0] === '/') {
debug('baseUrl with a leading slash detected');
resolutionDirectory = resolutionDirectory.replace(config.baseUrl, '');
debug('new resolution directory: ' + resolutionDirectory);
}
} else {
resolutionDirectory = path.dirname(options.filename);
debug('module resolution directory (based on filename): ' + resolutionDirectory);
}
if (normalizedModuleId[0] === '/') {
normalizedModuleId = normalizedModuleId.replace(/^\/+/g, '');
}
if (config.baseUrl[0] === '/') {
debug('baseUrl with a leading slash detected');
resolutionDirectory = resolutionDirectory.replace(config.baseUrl, '');
debug('new resolution directory: ' + resolutionDirectory);
requirejs.config(config);
normalizedModuleId = requirejs.toUrl(normalizedModuleId);
}
requirejs.config(config);
depPath = stripLoader(depPath);
let normalizedModuleId = requirejs.toUrl(depPath);
debug('requirejs normalized module id: ' + normalizedModuleId);

@@ -100,3 +104,3 @@

const foundFile = findFileLike(fileSystem, normalizedModuleId, resolved) || '';
const foundFile = findFileLike(resolved) || '';

@@ -112,13 +116,10 @@ if (foundFile) {

function findFileLike(fileSystem, partial, resolved) {
const fileDir = path.dirname(resolved);
function findFileLike(resolved) {
const pattern = resolved + '.*';
const pattern = escapeRegExp(resolved + '.');
debug('looking for file like ' + pattern);
debug('within ' + fileDir);
try {
const results = find.use({fs: fileSystem})
.fileSync(new RegExp(pattern), fileDir);
const results = glob.sync(pattern);
debug('found the following matches: ', results.join('\n'));

@@ -163,6 +164,2 @@

function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}
/**

@@ -169,0 +166,0 @@ * Exposed for testing

{
"name": "module-lookup-amd",
"version": "7.0.0",
"version": "7.0.1",
"description": "Resolve aliased dependency paths using a RequireJS config",

@@ -34,3 +34,3 @@ "main": "index.js",

"debug": "^4.1.0",
"find": "^0.3.0",
"glob": "^7.1.6",
"requirejs": "^2.3.5",

@@ -37,0 +37,0 @@ "requirejs-config-file": "^4.0.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