@@ -4,6 +4,7 @@ const fs = require('fs');
44const path = require ( 'path' ) ;
55
66const HANDLEBARS_REGEX = / \. ( h b s | h a n d l e b a r s ) $ / ;
7+ const JAVASCRIPT_REGEX = / \. ( j s ) $ / ;
78
89const NODE_MODULE_DIRECTORIES = [
910 path . join ( __dirname , '../node_modules' ) ,
@@ -28,13 +29,7 @@ const findPackagePath = pkg =>
2829
2930 fs . stat ( path , ( err , stats ) => {
3031
31- if ( err ) {
32-
33- return resolve ( null ) ;
34-
35- }
36-
37- if ( stats . isDirectory ( ) ) {
32+ if ( ! err && stats . isDirectory ( ) ) {
3833
3934 return resolve ( path ) ;
4035
@@ -80,6 +75,7 @@ const loadParser = config => new Promise((resolve, reject) => {
8075 *
8176 * loadPlugin({'layout': 'markdown'}).then(plugin => {});
8277 * loadPlugin({'layout': 'templates/README.hbs'}).then(plugin => {});
78+ * loadPlugin({'layout': 'plugin.js'}).then(plugin => {});
8379 *
8480 * @param {Object } config Configuration object.
8581 * @param {String } config.layout String representing the layout plugin to be loaded.
@@ -111,6 +107,10 @@ const loadPlugin = config => new Promise((resolve, reject) => {
111107
112108 resolve ( require ( 'doxdox-plugin-handlebars' ) ) ;
113109
110+ } else if ( stats && stats . isFile ( ) && config . layout . match ( JAVASCRIPT_REGEX ) ) {
111+
112+ resolve ( require ( `${ process . cwd ( ) } /${ config . layout } ` ) ) ;
113+
114114 } else {
115115
116116 reject ( 'Invalid layout specified.' ) ;
0 commit comments