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

include-folder

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

include-folder - npm Package Compare versions

Comparing version 0.9.0 to 1.0.0

113

lib/include-folder.js

@@ -1,9 +0,1 @@

/*
* include-folder
* https://github.com/parroit/include-folder
*
* Copyright (c) 2013 parroit
* Licensed under the MIT license.
*/
'use strict';

@@ -13,71 +5,70 @@

function includeFolder(folderName, filter, options) {
folderName = folderName.replace(/\/$/, '');
function includeFolder (folderName, filter, options) {
folderName = folderName.replace(/\/$/, '');
if (!filter) {
filter = /^[^.].*$/;
}
if (!filter) {
filter = /^[^.].*$/;
}
if (typeof options !== 'object') {
options = {};
}
if (typeof options !== 'object') {
options = {};
}
var source = includeFolder.buildSource(folderName, filter, options);
/*jshint -W054 */
return (new Function('require', '__dirname', source))(require, folderName);
var source = includeFolder.buildSource(folderName, filter, options);
return (new Function('require', '__dirname', source))(require, folderName); // eslint-disable-line no-new-func
}
includeFolder.normalize = function(name) {
var chars = [];
var nextUpper = false;
var i = 0,
l = name.length;
includeFolder.normalize = function (name) {
var chars = [];
var nextUpper = false;
var i = 0;
var l = name.length;
for (; i < l; i++) {
var c = name.charAt(i);
if (/\w/.test(c)) {
chars.push(nextUpper ? c.toUpperCase() : c);
nextUpper = false;
} else {
nextUpper = true;
}
for (; i < l; i++) {
var c = name.charAt(i);
if (/\w/.test(c)) {
chars.push(nextUpper ? c.toUpperCase() : c);
nextUpper = false;
} else {
nextUpper = true;
}
name = chars.join('');
return name;
}
name = chars.join('');
return name;
};
includeFolder.stripExtension = function(fileName) {
return fileName.replace(/^\./, '').replace(/\.[^/.]+$/, '');
includeFolder.stripExtension = function (fileName) {
return fileName.replace(/^\./, '').replace(/\.[^/.]+$/, '');
};
includeFolder.buildSource = function(folderName, filter, options) {
var files = fs.readdirSync(folderName);
var allProps = {};
filter = filter.test.bind(filter);
var fields = files.filter(filter).map(function(fileName) {
var name = includeFolder.normalize(
includeFolder.stripExtension(fileName, options),
options
);
includeFolder.buildSource = function (folderName, filter, options) {
var files = fs.readdirSync(folderName);
var allProps = {};
filter = filter.test.bind(filter);
var fields = files.filter(filter).map(function (fileName) {
var name = includeFolder.normalize(
includeFolder.stripExtension(fileName, options),
options
);
if (options && options.preserveFilenames === true) {
name = fileName;
}
if (options && options.preserveFilenames === true) {
name = fileName;
}
if (name in allProps) {
allProps[name]++;
name += '_' + allProps[name];
} else {
allProps[name] = 0;
}
if (name in allProps) {
allProps[name]++;
name += '_' + allProps[name];
} else {
allProps[name] = 0;
}
return 'self["' + name + '"] = fs.readFileSync("' + folderName + '/' + fileName + '","utf8");';
});
return 'self["' + name + '"] = fs.readFileSync("' + folderName + '/' + fileName + '","utf8");';
});
return 'var self={},' +
'fs = require("fs");\n' +
fields.join('\n') +
'\nreturn self';
return 'var self={},' +
'fs = require("fs");\n' +
fields.join('\n') +
'\nreturn self';
};
module.exports = includeFolder;
module.exports = includeFolder;
{
"name": "include-folder",
"description": "expose the content of each file in a folder as an object property.",
"version": "0.9.0",
"version": "1.0.0",
"homepage": "https://github.com/parro-it/include-folder",

@@ -10,2 +10,5 @@ "author": {

},
"eslintConfig": {
"extends": "eslint-config-semistandard"
},
"repository": {

@@ -18,8 +21,3 @@ "type": "git",

},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/parro-it/include-folder/blob/master/LICENSE-MIT"
}
],
"license": "MIT",
"main": "lib/include-folder",

@@ -30,8 +28,12 @@ "engines": {

"scripts": {
"test": "jshint lib/*.js test/*.js && mocha test/*.js",
"test": "eslint lib/*.js test/*.js && mocha test/*.js",
"prepublish": "npm run test",
"watch": "mocha --watch test/*.js"
},
"devDependencies": {
"expect.js": "~0.2.0",
"jshint": "^2.7.0",
"eslint": "^1.2.1",
"eslint-config-semistandard": "^5.0.0",
"eslint-config-standard": "^4.1.0",
"eslint-plugin-standard": "^1.2.0",
"expect.js": "^0.2.0",
"mocha": "^2.2.4"

@@ -38,0 +40,0 @@ },

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