Skip to content

Commit

Permalink
v2.2.0 Updated dependencyMapper again
Browse files Browse the repository at this point in the history
  • Loading branch information
Raynos committed Jun 2, 2012
1 parent a76c007 commit 6729031
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
21 changes: 20 additions & 1 deletion modules/dependencyMapper.js
Expand Up @@ -143,7 +143,26 @@ function findProxyObject(uri, proxyName, callback) {
var proxyObject = {},
folderUri = path.join(uri, proxyName)

fs.readdir(folderUri, mapIntoProxyObject)
iterateFiles(folderUri, function (fileName) {
var relativePropertyName = path.relative(folderUri, fileName),
relativeValue = path.relative(uri, fileName)

relativePropertyName = relativePropertyName.replace(isFile, "")
var props = relativePropertyName.split("/")

props.reduce(function (memo, value, index) {
if (index === props.length - 1) {
memo[value] = relativeValue
} else {
return (memo[value] = memo[value] || {})
}
}, proxyObject)

}, function (err) {
callback(err, proxyObject)
})

//fs.readdir(folderUri, mapIntoProxyObject)

function mapIntoProxyObject(err, files) {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ncore",
"version": "2.1.0",
"version": "2.2.0",
"description": "Core library for your application",
"keywords": ["core", "architecture", "infrastructure"],
"author": "Raynos <raynos2@gmail.com>",
Expand Down
7 changes: 7 additions & 0 deletions test/dependencyMapper.js
Expand Up @@ -49,6 +49,13 @@ suite("dependencyMapper", function () {
"baz": "shallow/foo/baz.js"
})

assert.deepEqual(json["deep/foo.js"]["tree"], {
foo: {
bar: "shallow/foo/bar.js",
baz: "shallow/foo/baz.js"
}
})

assert.equal(json["shallow/foo/bar.js"]["deep"], "deep/foo.js")

assert.equal(json["shallow/foo/baz.js"]["deep"], "deep/foo.js")
Expand Down
3 changes: 2 additions & 1 deletion test/modules/dependency.json
Expand Up @@ -10,7 +10,8 @@
"foobar": "bar"
},
"deep": {
"shallow": "shallow"
"shallow": "shallow",
"tree": ["shallow"]
},
"shallow": {
"deep": "deep"
Expand Down

0 comments on commit 6729031

Please sign in to comment.