Skip to content

Commit

Permalink
Merge pull request #326 from Delapouite/dev
Browse files Browse the repository at this point in the history
added config.ignorePatterns option
  • Loading branch information
balupton committed Oct 22, 2012
2 parents 3db3430 + 00360d0 commit 8d8118c
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/lib/docpad.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ class DocPad extends EventEmitterEnhanced
'plugins'
]

# Ignored files patterns during directory parsing
# Default to balUtil.commonIgnorePatterns
ignorePatterns: true


# -----------------------------
# Server
Expand Down Expand Up @@ -1531,7 +1535,7 @@ class DocPad extends EventEmitterEnhanced
# next(err)
parseDirectory: (opts={},next) ->
# Prepare
me = @
docpad = @
locale = @getLocale()

# Extract
Expand All @@ -1541,21 +1545,21 @@ class DocPad extends EventEmitterEnhanced
# Check if the directory exists
unless balUtil.existsSync(path)
# Log
me.log 'debug', util.format(locale.renderDirectoryNonexistant, path)
docpad.log 'debug', util.format(locale.renderDirectoryNonexistant, path)

# Forward
return next()

# Log
me.log 'debug', util.format(locale.renderDirectoryParsing, path)
docpad.log 'debug', util.format(locale.renderDirectoryParsing, path)

# Files
balUtil.scandir(
# Path
path: path

# Ignore common patterns
ignorePatterns: true
# Ignore patterns
ignorePatterns: docpad.config.ignorePatterns

# File Action
fileAction: (fileFullPath,fileRelativePath,nextFile,fileStat) ->
Expand All @@ -1579,10 +1583,10 @@ class DocPad extends EventEmitterEnhanced
return next(err) if err

# Log
me.log 'debug', util.format(locale.renderDirectoryParsed, path)
docpad.log 'debug', util.format(locale.renderDirectoryParsed, path)

# Load the files
me.loadFiles {collection:filesToLoad}, (err) ->
docpad.loadFiles {collection:filesToLoad}, (err) ->
# Forward
return next(err)
)
Expand Down Expand Up @@ -1751,8 +1755,8 @@ class DocPad extends EventEmitterEnhanced
# Path
path: pluginsPath

# Ignore common patterns
ignorePatterns: true
# Ignore patterns
ignorePatterns: docpad.config.ignorePatterns

# Skip files
fileAction: false
Expand Down Expand Up @@ -2508,6 +2512,9 @@ class DocPad extends EventEmitterEnhanced
locale = @getLocale()
database = @getDatabase()
watchrs = []
ignorePatterns = @config.ignorePatterns
if @config.ignorePatterns == true
ignorePatterns = balUtil.commonIgnorePatterns

# Close our watchers
closeWatchers = ->
Expand Down Expand Up @@ -2541,7 +2548,7 @@ class DocPad extends EventEmitterEnhanced
path: docpad.config.srcPath
listener: changeHandler
next: tasks.completer()
ignorePatterns: true
ignorePatterns: docpad.config.ignorePatterns
)

# Timer
Expand Down Expand Up @@ -2572,7 +2579,7 @@ class DocPad extends EventEmitterEnhanced
docpad.log 'debug', util.format(locale.watchChange, new Date().toLocaleTimeString()), eventName, filePath

# Check if we are a file we don't care about
if ( balUtil.commonIgnorePatterns.test(pathUtil.basename(filePath)) )
if ( ignorePatterns and ignorePatterns.test(pathUtil.basename(filePath)) )
docpad.log 'debug', util.format(locale.watchIgnoredChange, new Date().toLocaleTimeString()), filePath
return

Expand Down

0 comments on commit 8d8118c

Please sign in to comment.