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

requiredir

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

requiredir - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

5

CHANGELOG.md
Change Log
==============
## 2012-07-12 ##
* npm package version updated to 1.0.6
* Merged in changes from Joshua Poehls [jpoehls] concerning pathing issues.
* Added contributors section to README.
## 2012-07-10 ##

@@ -5,0 +10,0 @@ * npm package version updated to 1.0.5

2

package.json
{
"name": "requiredir",
"version": "1.0.5",
"version": "1.0.6",
"author": "James Eggers <james.r.eggers@gmail.com> (http://www.jamesreggers.com/)",

@@ -5,0 +5,0 @@ "description": "A module for importing a directory of Node.js modules and adding them into an array or as properties of the module variable.",

@@ -31,5 +31,11 @@ requiredir [![Build Status](https://secure.travis-ci.org/JamesEggers1/node-requiredir.png)](http://travis-ci.org/JamesEggers1/node-requiredir)

## Contributors ##
* James Eggers
* [Joshua Poehls](https://github.com/jpoehls)
## License ##
(MIT)
Copyright (c) 2012 James Eggers

@@ -36,0 +42,0 @@

@@ -8,3 +8,3 @@ "use strict";

var _verifyDirectory = function(path) {
var _verifyAndResolveDirectory = function(path) {
var stats;

@@ -14,20 +14,25 @@

|| (typeof path === "string" && path.trim().length === 0)) {
throw new TypeError("The path must be provided when instantiating the object.");
throw new Error("The path must be provided when instantiating the object.");
}
// Resolve the given require path relative to the parent module's directory.
// This way the user can provide paths that are relative to themselves.
path = _path.resolve(_path.dirname(module.parent.filename), path);
try {
stats = _fs.statSync(path);
} catch (e) {
throw new TypeError("The directory path does not exist.");
throw new Error("The directory path does not exist. [" + path + "]");
}
if (!stats.isDirectory()){
throw new TypeError("The path provided is not a directory.");
throw new Error("The path provided is not a directory. [" + path + "]");
}
return path;
};
var _importFiles = function(path, files){
var moduleList = []
, relativePath = _path.resolve(process.cwd() + "/" + path)
, trimmedName

@@ -38,5 +43,6 @@ , module

files.forEach(function (element, index, array){
if (_fs.lstatSync(path + "/" + element).isFile() && element.substring(0,1) !== "."){
trimmedName = element.substring(0, (element.length - 3));
module = require(relativePath + "/" + trimmedName);
// Require each file, skipping dotfiles.
if (_fs.lstatSync(_path.join(path, element)).isFile() && element.substring(0,1) !== "."){
trimmedName = _path.basename(element, _path.extname(element));
module = require(_path.join(path, trimmedName));
moduleList.push(module);

@@ -54,4 +60,5 @@ obj[trimmedName] = module;

return function(path){
_verifyDirectory(path);
path = _verifyAndResolveDirectory(path);
var fileList = []

@@ -58,0 +65,0 @@ , modules = [];

@@ -5,3 +5,4 @@ "use strict";

, _helpers = require("./test-helpers")
, requiredir = require("../src/requiredir");
, requiredir = require("../src/requiredir")
, _path = require("path");

@@ -24,7 +25,9 @@ describe("requiredir.js", function(){

it("should throw an exception if the path does not exist.", function(){
(function(){requiredir("./doesnotexist");}).should.throw("The directory path does not exist.");
var pathToTest = "./doesnotexist";
(function(){requiredir(pathToTest);}).should.throw("The directory path does not exist. [" + _path.resolve(__dirname, pathToTest) + "]");
});
it("should throw an exception if the path is not a directory.", function(){
(function(){requiredir("./LICENSE");}).should.throw("The path provided is not a directory.");
var pathToTest = "../LICENSE";
(function(){requiredir(pathToTest);}).should.throw("The path provided is not a directory. [" + _path.resolve(__dirname, pathToTest) + "]");
});

@@ -31,0 +34,0 @@ });

"use strict";
var _fs = require("fs")
, _os = require('os')
, _rimraf = require("rimraf");
, _os = require("os")
, _rimraf = require("rimraf")
, _path = require("path");

@@ -20,3 +21,3 @@ var eol = _os.platform

for (var i = 0; i < count; i++){
_fs.writeFileSync(path + '/mod' + i + '.js', index);
_fs.writeFileSync(_path.join(path, '/mod' + i + '.js'), index);
}

@@ -26,6 +27,8 @@ };

exports.createHiddenTestFiles = function(path){
_fs.writeFileSync(path + '/.hiddenFile.js', index);
path = _path.resolve(_path.dirname(module.parent.filename), path);
_fs.writeFileSync(_path.join(path, '/.hiddenFile.js'), index);
};
exports.setup = function(path, count){
path = _path.resolve(_path.dirname(module.parent.filename), path);
_fs.mkdirSync(path);

@@ -36,3 +39,4 @@ createTestFiles(path, count);

exports.teardown = function(path){
path = _path.resolve(_path.dirname(module.parent.filename), path);
_rimraf.sync(path);
};
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