Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3 from corpix/c5a19ad1f4978bd10fde705121a3c6785c9…

…17668

Improvements and refactoring :)
  • Loading branch information...
commit 42d14ee5f7ffa9329275557cd037483f2fb5d74d 2 parents a9bc53c + c5a19ad
@Pita authored
Showing with 8 additions and 7 deletions.
  1. +2 −2 index.js
  2. +6 −5 parser.js
View
4 index.js
@@ -52,8 +52,8 @@ try
if(!destValid)
{
- console.error("'"+destFolder + "' is no directory!");
- process.exit(1);
+ console.log("'"+destFolder + "' is no directory! I'll create it for you.");
+ fs.mkdirSync(destFolder);
}
//start recursive function
View
11 parser.js
@@ -1,4 +1,6 @@
-var fs = require("fs");
+var fs = require("fs")
+ , path = require('path')
+ , basename = path.basename;
/**
* 2011 Peter 'Pita' Martischka
@@ -27,19 +29,18 @@ exports.parseFile = function(baseFolder, filename)
var parsedObj = {};
//get the name of the module
- var name = filename.substr(filename.lastIndexOf("/")+1);
- name = filename.substr(0,name.lastIndexOf(".js"));
+ var name = basename(filename, '.js');
parsedObj.name = name;
//get the require path
- var requirePath = "./" + filename.replace(/.js$/,"");
+ var requirePath = "./" + name;
parsedObj.path = requirePath;
//read the file
var code = fs.readFileSync(baseFolder + "/" + filename, "utf8");
//search the comment of the document
- var docCommentRegExp = /^\s*\/\*\*((.|\n|\r)*?)\*\//m;
+ var docCommentRegExp = /^\s*\/\*\*?((.|\n|\r)*?)\*\//m;
var match = docCommentRegExp.exec(code);
if(match != null)
{
Please sign in to comment.
Something went wrong with that request. Please try again.