Skip to content

Commit ec022b7

Browse files
committedMay 8, 2015
Add CLI -c --config to set the path to the configuration file.
1 parent f1b5682 commit ec022b7

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
 

‎bin/apidoc

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ var argv = nomnom
3030
.option('template', { abbr: 't', 'default': path.join(__dirname, '../template/'),
3131
help: 'Use template for output files.' })
3232

33+
.option('config', { abbr: 'c', 'default': './', help: 'Path to config file (apidoc.json)' })
34+
3335
.option('verbose', { abbr: 'v', flag: true, 'default': false, help: 'Verbose debug output.' })
3436

3537
.option('help', { abbr: 'h', flag: true, help: 'Show this help information.' })
@@ -87,6 +89,7 @@ var options = {
8789
src : argv['input'],
8890
dest : argv['output'],
8991
template : argv['template'],
92+
config : argv['config'],
9093
verbose : argv['verbose'],
9194
debug : argv['debug'],
9295
parse : argv['parse'],

‎lib/package_info.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ PackageInfo.prototype.get = function() {
4545
_.extend(result, this._getHeaderFooter(result));
4646

4747
if (Object.keys(apidocJson).length === 0 && ! packageJson.apidoc)
48-
app.log.warn('Please create an apidoc.json.');
48+
app.log.warn('Please create an apidoc.json configuration file.');
4949

5050
return result;
5151
};
@@ -60,17 +60,16 @@ PackageInfo.prototype.get = function() {
6060
*/
6161
PackageInfo.prototype._readPackageData = function(filename) {
6262
var result = {};
63-
//var jsonFilename = path.join(app.options.src, filename);
6463
var dir = this._resolveSrcPath();
6564
var jsonFilename = path.join(dir, filename);
6665

67-
// read from source dir
66+
// Read from source dir
6867
if ( ! fs.existsSync(jsonFilename)) {
69-
// read vom current dir
70-
jsonFilename = './' + filename;
68+
// Read from config dir (default './')
69+
jsonFilename = path.join(app.options.config, filename);
7170
}
7271
if ( ! fs.existsSync(jsonFilename)) {
73-
app.log.debug(filename + ' not found!');
72+
app.log.debug(jsonFilename + ' not found!');
7473
} else {
7574
try {
7675
result = JSON.parse( fs.readFileSync(jsonFilename, 'utf8') );

0 commit comments

Comments
 (0)
Please sign in to comment.