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

directory-import

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-import - npm Package Compare versions

Comparing version 3.0.0-beta.8 to 3.0.0-beta.9

4

dist/import-modules.js

@@ -7,5 +7,5 @@ "use strict";

const node_path_1 = __importDefault(require("node:path"));
const constants_1 = require("./constants");
const directory_reader_async_1 = __importDefault(require("./directory-reader-async"));
const directory_reader_sync_1 = __importDefault(require("./directory-reader-sync"));
const VALID_IMPORT_EXTENSIONS = new Set(['.js', '.ts', '.json']);
const handlers = { async: asyncHandler, sync: syncHandler };

@@ -44,3 +44,3 @@ /**

const { name: fileName, ext: fileExtension } = node_path_1.default.parse(filePath);
const isValidModuleExtension = constants_1.VALID_IMPORT_EXTENSIONS.includes(fileExtension);
const isValidModuleExtension = VALID_IMPORT_EXTENSIONS.has(fileExtension);
if (!isValidModuleExtension)

@@ -47,0 +47,0 @@ return;

@@ -16,5 +16,10 @@ "use strict";

const options = (0, prepare_private_options_1.default)(...arguments_);
options.callerFilePath = new Error('Expexted error').stack?.split('\n')[2]?.match(/\(([^)]+)\)/)?.[1];
return (0, import_modules_1.default)(options);
try {
return (0, import_modules_1.default)(options);
}
catch (error) {
Object.assign(error, options);
throw error;
}
}
exports.directoryImport = directoryImport;

@@ -7,3 +7,19 @@ "use strict";

const node_path_1 = __importDefault(require("node:path"));
const constants_1 = require("./constants");
const getDefaultOptions = () => {
const options = {
includeSubdirectories: true,
importMode: 'sync',
importPattern: /.*/,
limit: Number.POSITIVE_INFINITY,
callerFilePath: '/',
callerDirectoryPath: '/',
targetDirectoryPath: '/',
};
options.callerFilePath = new Error('functional-error').stack
.split('\n')[4]
?.match(/\(([^)]+)\)/)?.[1];
options.callerDirectoryPath = options.callerFilePath.split('/').slice(0, -1).join('/');
options.targetDirectoryPath = options.callerDirectoryPath;
return options;
};
/**

@@ -15,3 +31,3 @@ * Prepare the options object from the provided arguments.

function preparePrivateOptions(...arguments_) {
const options = { ...constants_1.DEFAULT_IMPORT_MODULES_PRIVATE_ARGUMENTS };
const options = { ...getDefaultOptions() };
// * Check first argument

@@ -29,3 +45,3 @@ // ** If user provided nothing as first argument,

return {
...constants_1.DEFAULT_IMPORT_MODULES_PRIVATE_ARGUMENTS,
...getDefaultOptions(),
...arguments_[0],

@@ -32,0 +48,0 @@ };

{
"name": "directory-import",
"version": "3.0.0-beta.8",
"version": "3.0.0-beta.9",
"description": "Module will allow you to synchronously or asynchronously import (requires) all modules from the folder you specify",

@@ -5,0 +5,0 @@ "main": "dist/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