dir-tree-creator
Advanced tools
Comparing version 1.0.0 to 1.0.2
@@ -7,3 +7,2 @@ (function() { | ||
function add_dir_to_tree(tree, parent_dir_to_find, dir_to_add) { | ||
var i; | ||
if (parent_dir_to_find === tree.label) { | ||
@@ -15,12 +14,12 @@ tree.nodes.push({ | ||
} else { | ||
for (i = 0; i < tree.nodes.length; i += 1) { | ||
if (typeof tree.nodes[i] === 'object' && tree.nodes[i].label === parent_dir_to_find) { | ||
tree.nodes[i].nodes.push({ | ||
tree.nodes.forEach(function(t_node) { | ||
if (typeof t_node === 'object' && t_node.label === parent_dir_to_find) { | ||
t_node.nodes.push({ | ||
label: dir_to_add, | ||
nodes: [] | ||
}); | ||
} else if (typeof tree.nodes[i] === 'object' && tree.nodes[i].label !== parent_dir_to_find) { | ||
add_dir_to_tree(tree.nodes[i], parent_dir_to_find, dir_to_add); | ||
} else if (typeof t_node === 'object' && t_node.label !== parent_dir_to_find) { | ||
add_dir_to_tree(t_node, parent_dir_to_find, dir_to_add); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -30,13 +29,12 @@ } | ||
function add_file_to_tree(tree, parent_dir_to_find, file_to_add) { | ||
var i; | ||
if (parent_dir_to_find === tree.label) { | ||
tree.nodes.push(file_to_add); | ||
} else { | ||
for (i = 0; i < tree.nodes.length; i += 1) { | ||
if (typeof tree.nodes[i] === 'object' && tree.nodes[i].label === parent_dir_to_find) { | ||
tree.nodes[i].nodes.push(file_to_add); | ||
} else if (typeof tree.nodes[i] === 'object' && tree.nodes[i].label !== parent_dir_to_find) { | ||
add_file_to_tree(tree.nodes[i], parent_dir_to_find, file_to_add); | ||
tree.nodes.forEach(function(t_node) { | ||
if (typeof t_node === 'object' && t_node.label === parent_dir_to_find) { | ||
t_node.nodes.push(file_to_add); | ||
} else if (typeof t_node === 'object' && t_node.label !== parent_dir_to_find) { | ||
add_file_to_tree(t_node, parent_dir_to_find, file_to_add); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -43,0 +41,0 @@ } |
{ | ||
"name": "dir-tree-creator", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "simple directory tree structure creator based on the given root path", | ||
@@ -5,0 +5,0 @@ "main": "dirTree.js", |
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
8104
84