Socket
Socket
Sign inDemoInstall

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 4.0.2 to 4.0.3

32

index.js
var ConfigFile = require('requirejs-config-file').ConfigFile;
var fs = require('fs');
var path = require('path');

@@ -13,4 +14,5 @@ var debug = require('debug')('lookup');

* @param {Object} options - Pass a loaded config object if you'd like to avoid rereading the config
* @param {String} options.partial - the dependency name
* @param {String} options.filename - the file containing the dependency
* @param {String} options.partial - The dependency name
* @param {String} options.filename - The file containing the dependency
* @param {String} [options.directory] - The directory to use for resolving absolute paths (when no config is used)
* @param {String|Object} [options.config] - Pass a loaded config object if you'd like to avoid rereading the config

@@ -22,5 +24,3 @@ * @param {String|Object} [options.configPath] - The location of the config file used to create the preparsed config object

module.exports = function(options) {
// If you want to supply a preparsed config object without a configPath, then
// we have no way of knowing what the baseUrl should be.
var configPath = options.configPath || options.filename;
var configPath = options.configPath;
var config = options.config || {};

@@ -35,3 +35,3 @@ var depPath = options.partial;

if (typeof config === 'string') {
configPath = config;
configPath = path.dirname(config);
config = module.exports._readConfig(config);

@@ -41,2 +41,6 @@ debug('converting given config file ' + configPath + ' to an object:\n', config);

if (configPath && !fs.statSync(configPath).isDirectory()) {
configPath = path.dirname(configPath);
}
debug('configPath: ', configPath);

@@ -49,5 +53,17 @@

var resolutionDirectory = path.dirname(configPath);
debug('module resolution directory: ' + resolutionDirectory);
var resolutionDirectory;
if (configPath) {
resolutionDirectory = configPath;
debug('module resolution directory (based on configPath): ' + resolutionDirectory);
} else if (options.directory && depPath[0] !== '.') {
resolutionDirectory = options.directory;
debug('module resolution directory (based on directory): ' + resolutionDirectory);
} else {
resolutionDirectory = path.dirname(options.filename);
debug('module resolution directory (based on filename): ' + resolutionDirectory);
}
if (config.baseUrl[0] === '/') {

@@ -54,0 +70,0 @@ debug('baseUrl with a leading slash detected');

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

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

### module-lookup-amd [![npm](http://img.shields.io/npm/v/module-lookup-amd.svg)](https://npmjs.org/package/module-lookup-amd) [![npm](http://img.shields.io/npm/dm/module-lookup-amd.svg)](https://npmjs.org/package/module-lookup-amd)
This module takes in a partial and synchronously gives back its absolute path on the filesystem.
> Resolve AMD dependency paths to an absolute path on the filesystem
This module takes in a partial and *synchronously* gives back its absolute path on the filesystem.
I built this for [Dependents'](https://sublime.wbond.net/packages/Dependents) [jump to dependency](https://github.com/mrjoelkemp/Dependents#jump-to-a-dependency) feature that lets you click on a module name

@@ -18,3 +20,4 @@ and open the relevant file.

filename: 'file/containing/partial',
config: 'path/to/my/requirejs/config' // optional if not using paths/map aliasing
directory: 'path/to/all/js/files', // optional
config: 'path/to/my/requirejs/config' // optional
});

@@ -25,5 +28,6 @@ ```

* `filename`: the path of the file that contains the dependency (i.e., parent module)
* `directory`: Used to resolve files if you're not using a requirejs config
* `config`: the path to your RequireJS configuration file
* As an optimization, you can provide a pre-parsed config object (the contents of the RequireJS config in object form)
as `config`. You are then required to provide a `configPath` argument which is the full path to your config file.
as `config`. You are then required to provide a `directory` argument which is assumed to be the location where your config would have been.

@@ -35,1 +39,5 @@ ### Shell usage

`lookup-amd -c path/to/my/config.js -f path/to/file/containing/dependency -d path/containing/all/files my/dependency/name`
### License
MIT

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