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

acquire

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acquire - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

26

index.js

@@ -5,4 +5,6 @@ 'use strict';

getModuleName = require('filename-to-module-name'),
validateNpmPackageName = require('validate-npm-package-name'),
zipmap = require('zipmap'),
xtend = require('xtend');
xtend = require('xtend'),
callsites = require('callsites');

@@ -21,2 +23,8 @@ var fs = require('fs'),

var validateModuleName = function (name) {
var v = validateNpmPackageName(name);
return v.validForOldPackages || v.validForNewPackages;
};
var safeResolve = function (modulePath) {

@@ -30,4 +38,7 @@ try {

var acquire = function acquire(basedir, opts) {
var modules = acquire.resolve(basedir, opts);
var acquire = function acquire(opts) {
opts = opts || {};
opts.basedir = opts.basedir || path.dirname(callsites()[1].getFileName());
var modules = acquire.resolve(opts);
Object.keys(modules).forEach(function (m) {

@@ -40,7 +51,8 @@ modules[m] = require(modules[m]);

acquire.resolve = function (basedir, opts) {
acquire.resolve = function (opts) {
opts = opts || {};
opts.basedir = opts.basedir || path.dirname(callsites()[1].getFileName());
opts.depth = opts.depth || 1;
var dirs = nodeModulesPaths(basedir)
var dirs = nodeModulesPaths(opts.basedir)
.slice(0, opts.depth)

@@ -51,2 +63,6 @@ .reverse();

return zipmap(fs.readdirSync(dir).map(function (basename) {
if (!validateModuleName(basename)) {
return;
}
var modulePath = path.resolve(dir, basename);

@@ -53,0 +69,0 @@ var moduleName = getModuleName(modulePath);

4

package.json
{
"name": "acquire",
"version": "0.1.0",
"version": "0.2.0",
"description": "Require all modules from the node_modules directory, using Node module resolution algorithm to discover it",

@@ -31,4 +31,6 @@ "author": "Eugene Sharygin <eush77@gmail.com>",

"dependencies": {
"callsites": "^1.0.0",
"filename-to-module-name": "^0.1.1",
"find-node-modules": "^1.0.1",
"validate-npm-package-name": "^2.0.1",
"xtend": "^4.0.0",

@@ -35,0 +37,0 @@ "zipmap": "^1.1.1"

@@ -16,5 +16,5 @@ [![npm](https://nodei.co/npm/acquire.png)](https://nodei.co/npm/acquire/)

### `acquire(basedir, [opts])`
### `acquire([opts])`
Require all modules in `node_modules`, starting from the `basedir`.
Require all modules in `node_modules`, starting from `opts.basedir`.

@@ -30,6 +30,7 @@ Returns object of all the modules required:

| Option | Type | Required? | Default |
| :----------- | :------ | :-------: | :------ |
| depth | number | No | `1` |
| skipFailures | boolean | No | `false` |
| Option | Type | Required? | Default |
| :----------- | :------ | :-------: | :---------- |
| basedir | string | No | `__dirname` |
| depth | number | No | `1` |
| skipFailures | boolean | No | `false` |

@@ -40,5 +41,5 @@ If `opts.depth` is finite, it specifies the number of `node_modules` directories up the directory tree to traverse into. If `opts.depth` is `Infinity`, traversal ends at the file system root.

### `acquire.resolve(basedir, [opts])`
### `acquire.resolve([opts])`
Require.resolve all modules in `node_modules`, starting from the `basedir`.
Require.resolve all modules in `node_modules`, starting from `opts.basedir`.

@@ -45,0 +46,0 @@ Returns object of all the modules and corresponding paths:

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