Skip to content

Commit

Permalink
Misc fixes to pathing lookups, addressed the error condition (no file…
Browse files Browse the repository at this point in the history
…s pass in )
  • Loading branch information
drewwells committed Jul 25, 2011
1 parent 652a77e commit 779fa05
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions jodoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
var fs = require('fs'),
path = require('path'),
jodoc = require(__dirname + '/lib/jodoc-lib.js'),
markdown = require(__dirname + '/lib/showdown.js').showdown;
markdown = require(__dirname + '/lib/showdown.js').showdown,
prefix = process.cwd();

var sys = require('sys'),
http = require('http');
Expand All @@ -12,7 +13,7 @@ var sys = require('sys'),
function getOptions() {

var args = process.argv.slice(2),
config,
configFile = process.argv[2],
arg = '',
options = {
files: []
Expand All @@ -21,12 +22,16 @@ function getOptions() {
if( args.length === 1 ){

try{
if( configFile[0] !== '/' ){

config = require( process.argv[2] );
return config;
configFile = path.resolve( prefix, configFile );
}

return require( configFile );
} catch ( err ){

sys.puts( "Configuration module not found or failed to load, is it a value CommonJS module?" );
throw "Error";
}

} else {
Expand Down Expand Up @@ -161,11 +166,11 @@ function readFileContent( files, output, toc ){
(function( ) {

var options = getOptions(), //Parse command line arguments
files = options.files,
files = options.files || [],
content;

// if no files given, glob the current directory
if (!files.length) {
if ( !files.length) {
files.push('.');
}

Expand All @@ -184,7 +189,7 @@ function readFileContent( files, output, toc ){
if( filePath !== './' ){

filePath = path.join( options.output, filePath );
console.log( filePath );

path.exists(filePath, function(exists) {

if( exists ){
Expand Down

0 comments on commit 779fa05

Please sign in to comment.