/*
 * grunt-docs
 * https://github.com/shama/grunt-docs
 *
 * Copyright (c) 2013 Kyle Robinson Young
 * Licensed under the MIT license.
 */

module.exports = function(grunt) {
  'use strict';

  var docpad = require('docpad');

  grunt.registerTask('docs', 'Compile with DocPad', function() {
    var done = this.async();
    var config = grunt.config(this.name || 'docs');
    var srcPath = config.srcPath || 'src';

    // To allow paths config to use patterns
    Object.keys(config).forEach(function(key) {
      if (key.slice(-5) === 'Paths') {
        var options = {};

        switch (key) {
        case 'documentsPaths':
        case 'filesPaths':
        case 'layoutsPaths':
          options.cwd = srcPath;
          break;
        }

        config[key] = grunt.file.expand(options, config[key]);
      }
    });

    docpad.createInstance(config, function(err, inst) {
      inst.action('generate', function(err) {
        if (err) { return grunt.warn(err); }
        done();
      });
    });
  });

};

/*
 * grunt-docs
 * https://github.com/shama/grunt-docs
 *
 * Copyright (c) 2013 Kyle Robinson Young
 * Licensed under the MIT license.
 */

module.exports = function(grunt) {
  'use strict';

  var docpad = require('docpad');

  grunt.registerTask('docs', 'Compile with DocPad', function() {
    var done = this.async();
    var config = grunt.config(this.name || 'docs');

    // To allow paths config to use patterns
    Object.keys(config).forEach(function(key) {
      if (key.slice(-5) === 'Paths') {
        config[key] = grunt.file.expand(config[key]);
      }
    });

    docpad.createInstance(config, function(err, inst) {
      inst.action('generate', function(err) {
        if (err) { return grunt.warn(err); }
        done();
      });
    });
  });

};

--- 
+++ 
@@ -14,11 +14,22 @@
   grunt.registerTask('docs', 'Compile with DocPad', function() {
     var done = this.async();
     var config = grunt.config(this.name || 'docs');
+    var srcPath = config.srcPath || 'src';
 
     // To allow paths config to use patterns
     Object.keys(config).forEach(function(key) {
       if (key.slice(-5) === 'Paths') {
-        config[key] = grunt.file.expand(config[key]);
+        var options = {};
+
+        switch (key) {
+        case 'documentsPaths':
+        case 'filesPaths':
+        case 'layoutsPaths':
+          options.cwd = srcPath;
+          break;
+        }
+
+        config[key] = grunt.file.expand(options, config[key]);
       }
     });
 
Set the correct Grunt working directory.

Since `documentsPaths`, `filesPaths`, and `layoutsPaths` are all
relative to `srcPath`, the working directory needs to be set before
performing the file expansion.
