Socket
Socket
Sign inDemoInstall

enhanced-require

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enhanced-require - npm Package Compare versions

Comparing version 0.4.0-beta10 to 0.4.0-beta11

0

bin/enhanced-require-hot-watch.js

@@ -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 @@ /*

9

lib/RequireContext.js

@@ -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");

2

package.json
{
"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

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