include-folder
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -44,2 +44,5 @@ /* | ||
function stripExtension(fileName) { | ||
if (fileName.charAt(0) === ".") | ||
fileName = fileName.substring(1); | ||
return fileName.replace(/\.[^/.]+$/, ""); | ||
@@ -73,3 +76,5 @@ } | ||
includeFolder._testHook = { | ||
buildSource: buildSource | ||
buildSource: buildSource, | ||
normalize: normalize, | ||
stripExtension: stripExtension | ||
}; | ||
@@ -76,0 +81,0 @@ |
{ | ||
"name": "include-folder", | ||
"description": "expose the content of each file in a folder as an object property.", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"homepage": "https://github.com/parroit/include-folder", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -8,8 +8,29 @@ 'use strict'; | ||
describe("include_folder", function () { | ||
it("is defined", function () { | ||
describe("normalize", function() { | ||
it("handles .DS_Store",function() { | ||
var normalized = includeFolder._testHook.normalize(".DS_Store"); | ||
expect(normalized).to.be.equal("DS_Store"); | ||
}); | ||
}); | ||
describe("stripExtension", function() { | ||
it("remove extension",function() { | ||
var normalized = includeFolder._testHook.stripExtension("test.txt"); | ||
expect(normalized).to.be.equal("test"); | ||
}); | ||
it("handles hidden files",function() { | ||
var normalized = includeFolder._testHook.stripExtension(".txt"); | ||
expect(normalized).to.be.equal("txt"); | ||
}); | ||
}); | ||
describe("include_folder", function() { | ||
it("is defined", function() { | ||
expect(includeFolder).to.be.an('function'); | ||
}); | ||
it("has test hook", function () { | ||
it("has test hook", function() { | ||
expect(includeFolder._testHook).to.be.an('object'); | ||
@@ -19,3 +40,3 @@ }); | ||
function moduleCheck(folderModule) { | ||
it("is an object", function () { | ||
it("is an object", function() { | ||
expect(folderModule).to.be.an('object'); | ||
@@ -25,19 +46,19 @@ }); | ||
it("has a property for each file", function () { | ||
expect(_.keys(folderModule).length).to.be.equal(3); | ||
it("has a property for each file", function() { | ||
expect(_.keys(folderModule).length).to.be.equal(4); | ||
}); | ||
it("extension is stripped from file names", function () { | ||
it("extension is stripped from file names", function() { | ||
expect("file1" in folderModule).to.be.equal(true); | ||
}); | ||
it("duplicated file names properties are incremented", function () { | ||
it("duplicated file names properties are incremented", function() { | ||
expect("file1_1" in folderModule).to.be.equal(true); | ||
}); | ||
it("properties names are normalized", function () { | ||
it("properties names are normalized", function() { | ||
expect("file3OtherFile" in folderModule).to.be.equal(true); | ||
}); | ||
it("properties values are file content", function () { | ||
it("properties values are file content", function() { | ||
expect(folderModule.file1).to.be.equal("this is file1 content"); | ||
@@ -47,6 +68,9 @@ }); | ||
describe ("generated source code",function(){ | ||
var source = includeFolder._testHook.buildSource("./test/files"), | ||
folderModule = (new Function("require","__dirname",source))(require,__dirname+"/files/"); | ||
describe("generated source code", function() { | ||
var source, | ||
folderModule; | ||
source = includeFolder._testHook.buildSource("./test/files"), | ||
console.log(source) | ||
folderModule = (new Function("require", "__dirname", source))(require, __dirname + "/files/"); | ||
@@ -56,5 +80,6 @@ moduleCheck(folderModule); | ||
describe ("returned object",function(){ | ||
describe("returned object", function() { | ||
var folderModule = includeFolder("./test/files"); | ||
@@ -61,0 +86,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
15004
14
150