Skip to content

Commit d2defdb

Browse files
committed
Added support for multiple inputs.
1 parent 7d6c3b4 commit d2defdb

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

bin/doxdox

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@ var config = {
1111
layout: 'bootstrap'
1212
};
1313

14-
var input = process.cwd(),
14+
var input = [],
1515
output,
1616
pkg;
1717

1818
var args = process.argv.slice(2);
1919

20-
if (args.length && !args[0].match(/^\-/)) {
20+
if (args.length) {
2121

22-
input = args.shift();
22+
while (args.length && !args[0].match(/^\-/)) {
23+
24+
input.push(args.shift());
25+
26+
}
27+
28+
} else {
29+
30+
input = process.cwd();
2331

2432
}
2533

lib/doxdox.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,46 @@ module.exports.templates = {
1313
wiki: utils.buildWiki
1414
};
1515

16-
module.exports.parseInput = function (input, config, pkg) {
16+
module.exports.parseInput = function (inputs, config, pkg) {
1717

1818
var files = [],
1919
stat;
2020

21-
if (fs.existsSync(input)) {
21+
if (!Array.isArray(inputs)) {
2222

23-
stat = fs.statSync(input);
23+
inputs = [inputs];
2424

25-
if (stat.isDirectory()) {
25+
}
2626

27-
utils.walk(input).forEach(function (file) {
27+
inputs.forEach(function (input) {
2828

29-
files.push({
30-
name: file.replace(input, '').replace(/^[\.\/]{1,2}/, ''),
31-
contents: fs.readFileSync(file, 'utf8')
32-
});
29+
if (fs.existsSync(input)) {
3330

34-
});
31+
stat = fs.statSync(input);
3532

36-
} else if (stat.isFile()) {
33+
if (stat.isDirectory()) {
3734

38-
files.push({
39-
name: path.basename(input),
40-
contents: fs.readFileSync(input, 'utf8')
41-
});
35+
utils.walk(input).forEach(function (file) {
4236

43-
}
37+
files.push({
38+
name: file.replace(input, '').replace(/^[\.\/]{1,2}/, ''),
39+
contents: fs.readFileSync(file, 'utf8')
40+
});
4441

45-
} else {
42+
});
4643

47-
process.stdout.write('File or directory not found.\n');
48-
process.kill();
44+
} else if (stat.isFile()) {
4945

50-
}
46+
files.push({
47+
name: input,
48+
contents: fs.readFileSync(input, 'utf8')
49+
});
50+
51+
}
52+
53+
}
54+
55+
});
5156

5257
return exports.parseScripts(files, config, pkg);
5358

0 commit comments

Comments
 (0)