Skip to content

Commit

Permalink
multiple js file support in same folder added
Browse files Browse the repository at this point in the history
  • Loading branch information
karaxuna committed May 13, 2016
1 parent 95a22d2 commit 4c4d8f3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
Empty file modified bin/ngpack.bin.js
100644 → 100755
Empty file.
41 changes: 34 additions & 7 deletions commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,41 @@ module.exports = function(args){
['constants', 'controllers', 'directives', 'factories', 'filters', 'services'].forEach(function (n){
var t = module[n] = [];

if(fs.existsSync(path.join(modulesAbsPath, mn, n)))
fs.readdirSync(path.join(modulesAbsPath, mn, n)).forEach(function(name){
t.push({
name: name,
path: path.join(args.modules, mn, n, name),
content: fs.readFileSync(path.join(modulesAbsPath, mn, n, name, '/index.js'), 'utf8')
});
if(fs.existsSync(path.join(modulesAbsPath, mn, n))) {
fs.readdirSync(path.join(modulesAbsPath, mn, n)).forEach(function (name) {
/**
* @param {String} parentName
* @param {String} pathName
*/
(function parse(parentName, relativePath) {
fs.readdirSync(path.resolve(args.public, relativePath)).forEach(function (itemName) {
var itemRelativePath = path.join(relativePath, itemName);
var itemAbsPath = path.resolve(args.public, itemRelativePath);

if (itemName === 'index.js') {
t.push({
name: parentName,
path: relativePath,
content: fs.readFileSync(itemAbsPath, 'utf8')
});
} else {
var stats = fs.lstatSync(itemAbsPath);

if (stats.isDirectory()) {
parse(parentName + '/' + itemName, itemRelativePath);
}
else if (stats.isFile() && path.extname(itemName) === '.js') {
t.push({
name: parentName + '/' + itemName.substring(0, itemName.lastIndexOf(path.extname(itemName))),
path: relativePath,
content: fs.readFileSync(itemAbsPath, 'utf8')
});
}
}
});
})(name, path.join(args.modules, mn, n, name));
});
}
});
modules.push(module);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ngpack",
"description": "angularjs package manager",
"version": "2.0.3",
"version": "2.0.4",
"author": "Kakhaber Bazerashvili",
"homepage": "https://github.com/karaxuna/ngpack",
"repository": "git://github.com/karaxuna/ngpack.git",
Expand Down

0 comments on commit 4c4d8f3

Please sign in to comment.