0.2.0 • Published 9 years ago
@californian/require-local v0.2.0
require-local
require-local
is a tool for requiring packages from the local filesystem.
Paths to be imported (via require
) are defined in a javascript object. It
takes an object defining the paths to import and, optionally, a string defining
the format of the output. Bu default, it returns an eval-able string of require
statements, one for each leaf node in the object (and with variable names
matching the name of the file in the leaf node). If "array" is the second
argument, it returns an array of the functions of the leaf nodes. If "object"
is the second argument, it returns an object matching the input object, but
with the leaf nodes as keys whose values are the imported modules.
usage
var requireLocal = require("require-local");
requireLocalConfig = {
test: {
localPackages: {
a: {
b: ["c", "d"]
},
e: "f",
g: {
h: [
"i", {
j: ["k", "l"]
}
]
}
}
}
};
eval requireLocal(requireLocalConfig);
output
var c = require('YOUR-APP-ROOT-PATH/test/localPackages/a/b/c');
var d = require('YOUR-APP-ROOT-PATH/test/localPackages/a/b/d');
var f = require('YOUR-APP-ROOT-PATH/test/localPackages/e/f');
var i = require('YOUR-APP-ROOT-PATH/test/localPackages/g/h/i');
var k = require('YOUR-APP-ROOT-PATH/test/localPackages/g/h/j/k');
var l = require('YOUR-APP-ROOT-PATH/test/localPackages/g/h/j/l');