Skip to content

Commit

Permalink
fix: filter files but keep folders
Browse files Browse the repository at this point in the history
  • Loading branch information
David Longworth committed Apr 3, 2017
1 parent d7acf1d commit 3fe446d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions dadi/lib/providers/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ MarkdownProvider.prototype.processSortParameter = function processSortParameter
return sort
}

// Only get files that match the extension provided, or the default set above
// `file` is the absolute path to the file
MarkdownProvider.prototype.ignoreFunc = function (file, stats) {
console.log(this)
return path.extname(file) !== '.' + this.extension
}

/**
* load - loads data form the datasource
*
Expand All @@ -63,9 +56,13 @@ MarkdownProvider.prototype.load = function (requestUrl, done) {
const sourcePath = path.normalize(this.schema.datasource.source.path)

// Ignore files without the correct extension
recursive(sourcePath, [(file, stats) => { return path.extname(file) !== '.' + this.extension }], (err, filepaths) => {
recursive(sourcePath, (err, filepaths) => {
if (err) return done(err)

// Filter out only files with the correct extension
const extFilter = new RegExp('.' + this.extension + '$', 'i')
filepaths = filepaths.filter(i => extFilter.test(i))

// Process each file
async.map(filepaths, this.readFileAsync, (err, readResults) => {
if (err) return done(err, null)
Expand Down

0 comments on commit 3fe446d

Please sign in to comment.