Comparing version 0.1.1 to 0.1.2
12
index.js
@@ -17,10 +17,12 @@ 'use strict'; | ||
*/ | ||
function load(location) { | ||
function load(location, globals) { | ||
globals = globals || {}; | ||
if (!path.extname(location)) location = location +'.js'; | ||
location = path.resolve(path.dirname(module.parent.filename), location); | ||
return compiler(read(location), path.basename(location), { | ||
__filename: path.basename(location), | ||
__dirname: path.dirname(location) | ||
}); | ||
globals["__filename"] = path.basename(location); | ||
globals["__dirname"] = path.dirname(location); | ||
return compiler(read(location), path.basename(location), globals); | ||
} | ||
@@ -27,0 +29,0 @@ |
{ | ||
"name": "load", | ||
"version": "0.1.1", | ||
"description": "Load JavaScript files that do not use the bloat module patterns", | ||
"version": "0.1.2", | ||
"description": "Load plain JavaScript files that don't use module patterns directly in node.", | ||
"main": "index.js", | ||
@@ -26,4 +26,4 @@ "scripts": { | ||
"devDependencies": { | ||
"pre-commit": "0.0.4" | ||
"pre-commit": "0.0.x" | ||
} | ||
} |
# load | ||
[![Build Status](https://travis-ci.org/3rd-Eden/load.png)](https://travis-ci.org/3rd-Eden/load) | ||
[![NPM version](https://badge.fury.io/js/load.png)](http://badge.fury.io/js/load) | ||
Because fuck dedicated module patterns, module loaders, compilers and other kind | ||
@@ -4,0 +7,0 @@ of pointless code bloat that requires me to wrap my client-side JavaScript for |
@@ -22,2 +22,8 @@ 'use strict'; | ||
}, { | ||
it: 'passes optional argument globals to file scope', | ||
does: function does() { | ||
var lib = load('./fixtures/file3', {foo: 'bar'}); | ||
assert.equal(lib.getFoo(), 'bar'); | ||
} | ||
}, { | ||
it: 'adds nodejs globals to the code.', | ||
@@ -24,0 +30,0 @@ does: function () { |
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
7153
11
169
55