Skip to content

Commit

Permalink
Fix filter for directories. Update Node Modules to newer versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed May 28, 2013
1 parent 9d428dd commit ba1cc48
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function createOutputFiles(parsedFiles, parsedFilenames, packageInfos)
if( ! options.simulate) wrench.mkdirSyncRecursive(options.dest);

app.debug("copy template " + options.template + " to: " + options.dest);
if( ! options.simulate) wrench.copyDirSyncRecursive(options.template, options.dest);
if( ! options.simulate) wrench.copyDirSyncRecursive(options.template, options.dest, { forceDelete: true });

// api_data
var json = JSON.stringify(blocks, null, 2);
Expand Down
7 changes: 7 additions & 0 deletions lib/utils/find_files.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var fs = require("fs");
var path = require("path");
var wrench = require("wrench");

/**
Expand Down Expand Up @@ -27,6 +29,10 @@ function findFiles(options)
// RegExp Include Filter
var length = regExpIncludeFilters.length;
files = files.filter(function(filename) {
// Not include Directories like "dirname.js"
var fullFilename = path.join(options.src, filename);
if(fs.statSync(fullFilename).isDirectory()) return 0;
// Apply every filter
for(var i = 0; i < length; i += 1)
{
if(regExpIncludeFilters[i].test(filename)) return 1;
Expand All @@ -45,6 +51,7 @@ function findFiles(options)
// RegExp Exclude Filter
length = regExpExcludeFilters.length;
files = files.filter(function(filename) {
// Apply every filter
for(var i = 0; i < length; i += 1)
{
if(regExpExcludeFilters[i].test(filename)) return 0;
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apidoc",
"version": "0.1.10",
"version": "0.1.11",
"description": "RESTful web API Documentation Generator",
"author": "Peter Rottmann <[email protected]>",
"license": "MIT",
Expand All @@ -22,18 +22,18 @@
"node": ">= 0.8.0"
},
"dependencies": {
"wrench": "~1.4.4",
"wrench": "~1.5.1",
"underscore": "~1.4.4",
"semver": "~1.1.4",
"lodash": "~1.1.1",
"lodash": "~1.2.0",
"node-markdown": "~0.1.1",
"optimist": "~0.3.7",
"optimist": "~0.5.0",
"colors": "~0.6.0-1"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-clean": "~0.4.1",
"grunt-contrib-jshint": "~0.4.3",
"grunt-contrib-jshint": "~0.5.4",
"grunt-simple-mocha": "~0.4.0",
"should": "~1.2.2"
}
Expand Down
7 changes: 6 additions & 1 deletion test/apidoc_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe("apiDoc", function() {
// compare
it("case 1: created files should equal to fixtures", function(done) {
var timeRegExp = /"time"\:\s"(.*)"/g;
var versionRegExp = /"version"\:\s"(.*)"/g;
var slashesRegExp = /\\\\/g;
fixtureFiles.forEach(function(name) {
var fixtureContent = fs.readFileSync("test/fixtures/" + name, "utf8");
Expand All @@ -58,10 +59,14 @@ describe("apiDoc", function() {
fixtureContent = fixtureContent.replace(/\r\n/g, "\n");
createdContent = createdContent.replace(/\r\n/g, "\n");

// creation time remove.
// creation time remove (never equal)
fixtureContent = fixtureContent.replace(timeRegExp, "");
createdContent = createdContent.replace(timeRegExp, "");

// creation time remove (or fixtures must be updated every time the version change)
fixtureContent = fixtureContent.replace(versionRegExp, "");
createdContent = createdContent.replace(versionRegExp, "");

// windows path \\ to /
fixtureContent = fixtureContent.replace(slashesRegExp, "/");
createdContent = createdContent.replace(slashesRegExp, "/");
Expand Down

0 comments on commit ba1cc48

Please sign in to comment.