enhanced-require
Advanced tools
Comparing version 0.4.0-beta10 to 0.4.0-beta11
@@ -0,0 +0,0 @@ #!/usr/bin/env node |
@@ -0,0 +0,0 @@ # simple-server |
@@ -0,0 +0,0 @@ var pageTemplate = require("./page.jade"); |
@@ -0,0 +0,0 @@ var http = require("http"); |
@@ -0,0 +0,0 @@ require("../../")(module, { |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ var RequireContext = require("./RequireContext"); |
@@ -0,0 +0,0 @@ var fs = require("fs"); |
@@ -0,0 +0,0 @@ module.exports = function() { |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
@@ -320,3 +320,3 @@ var fs = require("fs"); | ||
RequireContext.prototype.theContext = function theContext(contextName) { | ||
return function(name) { | ||
var contextFn = function(name) { | ||
if(typeof name != "string" || name.substr(0, 2) != "./") | ||
@@ -326,4 +326,11 @@ throw new Error("A function created by require.context must be called with a string beginning with './'"); | ||
}.bind(this); | ||
contextFn.keys = function() { | ||
var request = resolve.context.sync(this.context, contextName, this.root.options.resolve); | ||
var requestObj = resolve.parse(request); | ||
var files = fs.readdirSync(requestObj.resource.path); | ||
return files.map(function(file) { return "./" + file; }); | ||
}.bind(this); | ||
return contextFn; | ||
} | ||
@@ -0,0 +0,0 @@ var RequireContext = require("./RequireContext"); |
{ | ||
"name": "enhanced-require", | ||
"version": "0.4.0-beta10", | ||
"version": "0.4.0-beta11", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Enhance the require function in node.js with support for loaders which preprocess files and really async require (AMD). Enables Hot Code Replacement.", |
@@ -0,0 +0,0 @@ # enhanced-require |
module.exports = 1; | ||
module.exports = { two: require("./circular2") }; |
module.exports = 2; | ||
module.exports = { one: require("./circular1") }; |
exports.module = module; | ||
exports.a = require("./graph/a.js"); | ||
exports.b = require("./graph/b.js"); |
module.exports = module; | ||
require("./b"); |
@@ -0,0 +0,0 @@ var should = require("should"); |
@@ -8,3 +8,3 @@ var should = require("should"); | ||
var context = req.context("./fixtures") | ||
beforeEach(function() { | ||
@@ -43,3 +43,33 @@ function clean(obj) { | ||
}); | ||
it("should be able to use a loader in require.context", function() { | ||
var context = req.context("raw!./fixtures"); | ||
var a = context("./directory/file2"); | ||
a.should.be.eql("module.exports = {value: \"file2\"};"); | ||
}); | ||
it("should be able to use context.keys()", function() { | ||
var context = req.context("./fixtures/graph"); | ||
should.exist(context.keys); | ||
context.keys.should.be.a("function"); | ||
var keys = context.keys(); | ||
should.exist(keys); | ||
keys.should.be.eql([ | ||
"./a.js", | ||
"./b.js" | ||
]); | ||
}); | ||
it("should be able to use context.keys() with loader", function() { | ||
var context = req.context("raw!./fixtures/graph"); | ||
should.exist(context.keys); | ||
context.keys.should.be.a("function"); | ||
var keys = context.keys(); | ||
should.exist(keys); | ||
keys.should.be.eql([ | ||
"./a.js", | ||
"./b.js" | ||
]); | ||
}); | ||
}); |
@@ -0,0 +0,0 @@ var should = require("should"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1897
1
67773